All problems

Find the Missing Number

mediumPythonArraysMath

The Hollybush Rooms hand out cloakroom tickets numbered 0 upward, one per coat, and on a full night every number up to n is in use. At closing the tickets come back in a heap and get typed into the desk terminal in whatever order they are pulled out of it. One ticket never comes back -- somebody walks off with it in a pocket -- and the duty manager needs that number, because it identifies the coat still hanging on the rail.

Task: Print the one number between 0 and n that is not in the returned list.

Input

The first line holds one integer n, the highest ticket number, with 1 <= n <= 1,000,000. The second line holds n integers separated by single spaces: the numbers 0 to n with exactly one of them absent. They arrive in no particular order.

Output

One line holding the missing number.

Example:

Input:
3
0 1 3

Output:
2

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…