All problems

Problem 794

Sum of Positive Numbers

Easy · 10 pts · Array, Basics

Problem

Add up only the positive numbers of the array (those greater than zero) and print the sum. Zeros and negative numbers are skipped. If the array has no positive number at all, the sum is 0. Use a 64-bit variable for the sum, because many large values can add up past 2^31.

Input

The first line contains an integer N, the size of the array. The second line contains N space-separated integers A[0], A[1], ..., A[N-1].

Output

Print the sum of the positive elements.

Constraints

1 <= N <= 100000; -10^9 <= A[i] <= 10^9

Example input

5
3 -1 4 0 -5

Example output

7

Explanation

In 3 -1 4 0 -5 the positive numbers are 3 and 4, so the answer is 7.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Binary to Decimal Next: Power of a Number