Competitions

# Introduction Contest

# White hats

There is a number of people in a room, and each of them wears a hat which is either black or white. Every person counts the number of other people wearing white hats. Find the total number of people wearing white hats, or tell that input data doesn't correspond to a valid situation.

#### Input

Each line gives one test. Each line contains the sequence of numbers `a`

, _{1}`a`

, ..., _{2}`a`

, where _{n}`a`

contains the number of hats counted by _{i}**i** - th man.

#### Output

For each test print on a separate line the number of people in white hats or **-1** if input data doesn't correspond to a valid situation.

Input example #1

2 1 1 2 2 2 10 10

Output example #1

2 3 -1