1039. Traveling

时间限制 1000 ms   内存限制 32 MB

SH likes traveling around the world. When he arrives at a city, he will ask the staff about the number of cities that connected with this city directly. After traveling around a mainland, SH will collate data and judge whether the data is correct.

 A group of data is correct when it can constitute an undirected graph.

输入数据

There are multiple test cases. The first line of each test case is a positive integer N (1<=N<=10000) standing for the number of cities in a mainland. The second line has N positive integers a1, a2, ...,an. ai stands for the number of cities that connected directly with the ith city. Input will be ended by the END OF FILE.

输出数据

If a group of data is correct, output "YES" in one line, otherwise, output "NO".

样例输入

复制
8
7 7 4 3 3 3 2 1
10
5 4 3 3 2 2 2 1 1 1
 \n
 · · · · · · · \n
  \n
 · · · · · · · · · \n

样例输出

复制
NO
YES

  \n
   \n
\n

提交

请先 登录

© 2024 FAQs Contact About