Sum of positive array elements
Java
Easy
arrays
Task «Sum of positive array elements»
Given an array of integers. Write a program that calculates the sum of all positive elements of the array. If there are no positive elements, output 0.
Input Format
The first line contains an integer N (1 ≤ N ≤ 1000) — the number of elements in the array. The second line contains N integers separated by spaces.
Output Format
One integer — the sum of positive elements.
Examples
Example 1
INPUT
1
42
OUTPUT
42
Example 2
INPUT
2
10 -10
OUTPUT
10
Example 3
INPUT
3
-5 -10 -3
OUTPUT
0
main.java