#C10980. Sum of Odd Integers
Sum of Odd Integers
Sum of Odd Integers
You are given an integer N representing the number of elements followed by an array of N integers. Your task is to calculate the sum of all odd integers in the array. Note that negative odd numbers should also be considered in the sum.
Mathematically, if the array is \(A = [a_1, a_2, \dots, a_N]\), then you have to compute:
\(\text{result} = \sum_{i=1}^{N} a_i \cdot \mathbb{1}_{\{a_i \mod 2 \neq 0\}}\)
inputFormat
The first line contains an integer N indicating the number of elements. The second line contains N space-separated integers representing the array elements.
outputFormat
Output a single integer which is the sum of all odd integers in the array.
## sample5
1 2 3 4 5
9