#C5092. Equal Marble Distribution
Equal Marble Distribution
Equal Marble Distribution
You are given n boxes, each containing a number of marbles. Your task is to determine whether it is possible to redistribute the marbles so that every box ends up with the same number of marbles. However, due to the nature of the moves, the only property that matters is the parity (evenness or oddness) of the number of marbles in each box.
In other words, it is possible to equalize the distribution if and only if all boxes initially have numbers that are either all even or all odd. An integer x is even if it satisfies \( x \equiv 0 \pmod{2} \) and odd if \( x \equiv 1 \pmod{2} \).
Print YES
if equitable redistribution is possible, or NO
otherwise.
inputFormat
The first line contains a single integer n
(1 ≤ n ≤ 10^5), representing the number of boxes. The second line contains n
space-separated integers, where the i-th integer represents the number of marbles in the i-th box.
outputFormat
Output a single line containing YES
if it is possible to redistribute the marbles so that every box ends up with the same number, or NO
otherwise.## sample
3
2 4 6
YES