#K76707. Count Even Sum Pairs

    ID: 34702 Type: Default 1000ms 256MiB

Count Even Sum Pairs

Count Even Sum Pairs

You are given a list of integers representing card values. Your task is to calculate the number of pairs (i, j) with i < j such that the sum of the two selected cards is even. The sum of two numbers is even if both numbers are even or both are odd.

Formally, if the number of even integers is even and the number of odd integers is odd, the answer is given by:

$$\binom{even}{2} + \binom{odd}{2} = \frac{even \times (even - 1)}{2} + \frac{odd \times (odd - 1)}{2} $$

Read the input from standard input and print the result to standard output.

inputFormat

The first line contains an integer n (n ≥ 2), representing the number of cards. The second line contains n space-separated integers, each representing a card's value.

outputFormat

Output a single integer representing the number of pairs (i, j) such that i < j and the sum of the values at positions i and j is even.

## sample
4
3 5 8 10
2

</p>