#d2677. 弗拉德和糖果 II
弗拉德和糖果 II
Vlad and Candies II
Problem Description
Not long ago, Vlad celebrated his birthday and received a package of candies. There are types of candies, and the -th type has pieces ().
Vlad decides to eat only one candy at a time. To get the most pleasure out of eating, Vlad does not want to eat two candies of the same type consecutively.
Help him figure out whether he can eat all the candies without ever eating two of the same type consecutively.
In short, given positive integers , where means there are copies of value , determine whether there exists a sequence that uses all the numbers with no two equal values adjacent.
Input Format
The first line contains an integer .
The second line contains positive integers.
Output Format
Output one line: if such a sequence exists, output YES; otherwise output NO.
Sample Input
2
1 1
Sample Output
YES
Sample Explanation
There are only two cases:
1 2
2 1
No matter which candy is eaten first, all candies can be finished without eating the same type consecutively.
Constraints
For of the data, , .