#C10851. Sum of Elements at Odd Indices
Sum of Elements at Odd Indices
Sum of Elements at Odd Indices
You are given a list of integers. Your task is to calculate the sum of those elements that are located at odd indices. Note that indexing is 0-based, i.e., the first element has index 0, the second element has index 1, and so on.
The required sum is given by:
[ S = \sum_{i \in {1,3,5,\dots}} a_i ]
If there are no elements at odd indices, output 0.
Input Format: The first line contains a single integer \(n\) denoting the number of elements in the list. The second line contains \(n\) space-separated integers representing the elements of the list.
Output Format: A single integer which is the sum of elements at odd indices.
inputFormat
The first line of input contains an integer \(n\) (\(0 \leq n \leq 10^5\)), the number of elements in the list. The second line contains \(n\) space-separated integers \(a_0, a_1, \dots, a_{n-1}\), each of which fits in a 32-bit signed integer.
outputFormat
Output a single integer representing the sum of the elements located at odd indices in the list.
## sample6
1 2 3 4 5 6
12