PythonEasyArrays10 min

Find the missing number from zero through n

The array contains n distinct numbers from this range. Exactly one range value is absent. Interviewers use this problem to assess xOR the complete range with the provided values.

Input

First line: n. Second line: n space-separated integers (empty when n = 0).

Output

Print the result on one line; print an empty line for an empty string.

Constraints

0 <= n <= 100000; all array values are distinct and between 0 and n.

Example

Input

3
3 0 1

Output

2

Example 2 input

5
5 4 3 2 1

Output

0

Zero can be the missing value.

Public test cases (2)

  • Input

    3
    3 0 1

    Expected output

    2
  • Input

    4
    0 1 2 3

    Expected output

    4
Hints (2)
  1. Identify the state needed to avoid repeated work.
  2. XOR the complete range with the provided values.

Target complexity: time O(n) · space O(1)

Your solution

Checking runner availability…

Reference solution

Sign in for solution
All Python programs