#C6120. Count Even Sum Pairs

    ID: 49846 Type: Default 1000ms 256MiB

Count Even Sum Pairs

Count Even Sum Pairs

Given an integer ( N ) and an array of ( N ) integers ( A ), find the number of distinct pairs ( (i, j) ) such that ( 1 \leq i < j \leq N ) and the sum ( A_i + A_j ) is even. Two numbers add up to an even number if either both are even or both are odd.

The formula for the number of pairs that can be formed from ( k ) elements is given by:
[ \binom{k}{2} = \frac{k \times (k-1)}{2} ]

Thus, if we count the number of even numbers as ( e ) and the number of odd numbers as ( o ), the answer is:
[ \frac{e(e-1)}{2} + \frac{o(o-1)}{2} ] Compute this value and output it.

inputFormat

The input is read from standard input (stdin).

The first line contains a single integer ( N ) representing the number of elements in the array.
The second line contains ( N ) space-separated integers representing the elements of the array ( A ).

outputFormat

Output a single integer representing the total number of distinct pairs ( (i, j) ) such that ( A_i + A_j ) is even, printed to standard output (stdout).## sample

5
1 2 3 4 5
4

</p>