#K52307. Sum of Even Numbers

    ID: 29280 Type: Default 1000ms 256MiB

Sum of Even Numbers

Sum of Even Numbers

Given an array of integers, calculate the sum of all even numbers in the array.

The problem is defined as follows: given an array \( A \) of length \( n \) where \( 1 \le n \le 1000 \) and each element \( A_i \) satisfies \( -10000 \le A_i \le 10000 \), compute the sum of all elements \( A_i \) such that \( A_i \equiv 0 \pmod{2} \). This must be accomplished in \( O(n) \) time using \( O(1) \) extra space.

Input is provided via stdin and the result should be output to stdout.

inputFormat

The first line contains an integer \( n \), the number of elements in the array.

The second line contains \( n \) space-separated integers representing the array elements.

outputFormat

Output a single integer representing the sum of all even numbers in the array.

## sample
5
1 2 3 4 5
6