#CCBCHMOT0000032. Tổng các số lẻ của dãy (Sum of Odd Elements)
Tổng các số lẻ của dãy (Sum of Odd Elements)
Sum of Odd Elements
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given n integers, sum exactly those whose remainder upon division by 2 is nonzero. Negative odd numbers contribute their signed value. An empty sequence has sum zero.
Input
An integer n followed by exactly n signed integers.
Output
Print the sum of all odd elements using a signed 64-bit integer.
Subtasks
- Subtask 1 (20%): , .
- Subtask 2 (30%): , .
- Subtask 3 (50%): , .
Examples
Example 1
Input
5
-3 2 7 8 -1
Output
3
Explanation
Odd elements -3,7,-1 sum to 3.
Example 2
Input
0
Output
0
Explanation
There are no elements, so the initialized sum remains zero.