|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||489||74||57||29.843%|
Football is one of the most popular sports in the world. There is a football league with n teams. A team plays against all the other teams and there is exactly one match for each pair of teams. Therefore, each team plays n − 1 matches. A draw is broken by the penalty shoot-out so there is no draw. After a match, if a team wins, it earns one point. If it loses, then it earns zero point.
After the match schedule is over, each team reports its point to the league office to decide the best team. The league office wants to be sure that each team made no mistake in reporting its point. Especially it wants to know whether the reported points are valid, that is, it is possible to assign those points to teams under the league rule.
Given n integers which are points reported by the teams, write a program to determine whether they are valid.
Your program is to read from standard input. The input consists of two lines. The first line contains an integer n (2 ≤ n ≤ 10,000) where n is the number of teams. The next line contains n integers which are points reported by teams. Each integer is between zero and n − 1, inclusive.
Your program is to write to standard output. Print 1 if the reported points are valid. Otherwise, print -1.
4 0 2 1 3
4 3 3 0 0