Sum of slice elements up to the first negative

Go Easy slices

Task «Sum of slice elements up to the first negative»

Write a program that reads integers from the console, stores them in a slice, then finds the sum of all elements of the slice up to the first negative number (excluding it). If there are no negative numbers, print the sum of all elements. If the slice is empty, the sum is 0.

Input Format

The first line contains an integer n (0 <= n <= 1000) — the number of elements. The second line contains n integers separated by spaces.

Output Format

One integer — the sum of elements before the first negative number.

Examples

Example 1

INPUT
5 1 2 -3 4 5
OUTPUT
3

Example 2

INPUT
3 5 3 1
OUTPUT
9
main.go