#C13753. Difference Between Sum of Even and Odd Indexed Elements

    ID: 43326 Type: Default 1000ms 256MiB

Difference Between Sum of Even and Odd Indexed Elements

Difference Between Sum of Even and Odd Indexed Elements

You are given a list of integers. Your task is to compute the difference between the sum of the elements at even indices and the sum of the elements at odd indices.

In other words, if the list is represented as \(a_0, a_1, a_2, \dots, a_{n-1}\), you should calculate:

[ \text{Result} = \sum_{i;\text{even}} a_i - \sum_{i;\text{odd}} a_i ]

Indices are 0-based. If the list is empty, output 0.

Note: The input is provided through standard input (stdin) where the first number represents the number of elements \(n\), followed by \(n\) integers separated by spaces.

inputFormat

The first line of input contains a single integer \(n\), representing the number of elements in the list. The second line contains \(n\) space-separated integers.

If \(n = 0\), the second line may be omitted or empty.

outputFormat

Print a single integer representing the difference between the sum of integers at even indices and the sum of integers at odd indices.

## sample
6
3 9 4 5 12 8
-3