#K53132. Count Even Sum Pairs
Count Even Sum Pairs
Count Even Sum Pairs
Given a list of ticket numbers, your task is to count the number of distinct pairs \((i, j)\) with \(1 \leq i < j \leq n\) such that the sum \(a_i + a_j\) is even. A sum is even if both numbers are even or both are odd.
Formally, if the list is \(A = [a_1, a_2, \dots, a_n]\), then the number of valid pairs is given by:
\( \binom{evenCount}{2} + \binom{oddCount}{2} \)
where \(evenCount\) is the number of even numbers and \(oddCount\) is the number of odd numbers in the list.
inputFormat
The first line contains an integer \(n\), the number of ticket numbers. The second line contains \(n\) space-separated integers representing the ticket numbers.
outputFormat
Output a single integer that is the number of distinct pairs whose sum is even.
## sample5
1 2 3 4 5
4