#K2341. Maximum Sum of Even Cards
Maximum Sum of Even Cards
Maximum Sum of Even Cards
Given a deck of cards with integer values, remove all odd-valued cards and calculate the sum of the remaining even-valued cards. Formally, if you have n cards with values \(a_1, a_2, \ldots, a_n\), your task is to compute \(\sum_{i=1}^{n} a_i \cdot \mathbf{1}_{\{a_i\text{ is even}\}}\) where \(\mathbf{1}\) is the indicator function.
The input is read from standard input (stdin) and the output is to be written to standard output (stdout).
Example:
Input: 5 1 2 3 4 5</p>Output: 6
inputFormat
The first line of input contains an integer n (the number of cards). The second line contains n space-separated integers representing the values of the cards.
\(1 \leq n \leq 10^5\) and each card value is in the range of \(0 \leq a_i \leq 10^9\).
outputFormat
A single integer representing the sum of all even-valued cards.
## sample5
1 2 3 4 5
6