eolymp
bolt
Try our new interface for solving problems
Problems

White hats

White hats

There are a number of people in a room, each wearing either a black or white hat. Every person counts the number of other people wearing white hats. Determine the total number of people wearing white hats, or indicate that the input data does not correspond to a valid situation. \InputFile Each line provides one test case, containing a sequence of numbers $a_1, a_2, ..., a_n~(n \le 100)$, where $a_i~(a_i \le 100)$ represents the number of hats counted by $i$ - th person. \OutputFile For each test case print on a separate line the number of people wearing white hats, or $-1$ if the input data does not correspond to a valid situation.
Time limit 1 second
Memory limit 128 MiB
Input example #1
2 1 1
2 2 2
10 10
Output example #1
2
3
-1