Find Missing NumberEasy

Find Missing Number

EasyPractice library · +10 XPbit manipulationxor tricks

Given a list of N distinct integers, where the integers are from the range [0, N], find the single integer that is missing from the list. The input list contains N numbers, and the complete range should contain N+1 numbers (from 0 to N inclusive).

Input

The first line contains an integer N. The second line contains N space-separated integers.

Output

Print the single missing integer.

Constraints

1 <= N <= 1000 All integers in the input list are distinct and within the range [0, N].

Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests

Example 1

Input
3
0 1 3
Output
2

N=3, numbers are from range [0,3]. Input has 0, 1, 3. Missing is 2.

Example 2

Input
2
0 2
Output
1

N=2, numbers are from range [0,2]. Input has 0, 2. Missing is 1.

Hints