#C9123. Sum of Positive Numbers
Sum of Positive Numbers
Sum of Positive Numbers
You are given an array of integers and your task is to compute the sum of all positive numbers in the array.
If the array is empty or it contains no positive numbers, the output should be 0
.
For example, given the array [1, -4, 7, 12]
, the positive numbers are 1, 7, 12
and their sum is 20
.
Note: The input to the program will be provided through standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The first line of input contains a single integer n
representing the number of elements in the array.
The second line contains n
space-separated integers.
outputFormat
Output a single integer representing the sum of all positive integers in the array. If there are no positive integers, output 0
.
4
1 -4 7 12
20
</p>