#agc016b. [agc016_b]Colorful Hats
[agc016_b]Colorful Hats
Problem Statement
There are cats. We number them from through .
Each of the cats wears a hat. Cat says: "there are exactly different colors among the hats worn by the cats except me."
Determine whether there exists a sequence of colors of the hats that is consistent with the remarks of the cats.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print Yes
if there exists a sequence of colors of the hats that is consistent with the remarks of the cats; print No
otherwise.
Sample Input 1
3
1 2 2
Sample Output 1
Yes
For example, if cat , and wears red, blue and blue hats, respectively, it is consistent with the remarks of the cats.
Sample Input 2
3
1 1 2
Sample Output 2
No
From the remark of cat , we can see that cat and wear hats of the same color. Also, from the remark of cat , we can see that cat and wear hats of the same color. Therefore, cat and wear hats of the same color, which contradicts the remark of cat .
Sample Input 3
5
4 3 4 3 4
Sample Output 3
No
Sample Input 4
3
2 2 2
Sample Output 4
Yes
Sample Input 5
4
2 2 2 2
Sample Output 5
Yes
Sample Input 6
5
3 3 3 3 3
Sample Output 6
No