#C7122. Rearrange to Palindrome
Rearrange to Palindrome
Rearrange to Palindrome
You are given a sequence of integers representing different types of potions. Determine whether the sequence can be rearranged to form a palindrome. A sequence can be rearranged into a palindrome if at most one type of integer appears an odd number of times. Formally, if we denote ( \text{odd_count} ) as the number of integers with odd frequency, then a palindrome can be formed if and only if ( \text{odd_count} \le 1 ).
inputFormat
Input is read from standard input (stdin). The first line contains a single integer ( n ) representing the number of potions. The second line contains ( n ) space-separated integers which represent the types of potions.
outputFormat
Output the result to standard output (stdout). Print YES
if the given sequence can be rearranged to form a palindrome, otherwise print NO
.## sample
5
1 2 3 2 1
YES