There are votes, represented by the array . Vote is for candidate .
You may rearrange the votes in any order. Determine whether there is an arrangement satisfying the following condition:
Whether the votes are counted from left to right or from right to left, after each vote is counted, exactly one candidate has strictly more counted votes than every other candidate.
The two counts are independent: all candidates start with zero counted votes in each direction.
The first line contains the number of votes .
The second line contains the votes .
Print Yes if a valid arrangement exists, and No otherwise.
You may print the answer in any combination of uppercase and lowercase letters. For example, Yes, YES, and YeS are all accepted.
One valid arrangement is .
From left to right, candidate has strictly more counted votes than every other candidate after each vote. The same is true from right to left.
Any valid arrangement must begin and end with a vote for candidate ; otherwise, candidate would lead initially but would not lead after all votes are counted.
The vote for candidate would then be in one of the two middle positions. Counting from the closer end, the first two votes would give one vote to each candidate, causing a tie.
The only vote is for candidate . After counting it from either direction, candidate is the unique leader.