#C7505. Find the Missing Number

    ID: 51384 Type: Default 1000ms 256MiB

Find the Missing Number

Find the Missing Number

You are given an array of n-1 unique integers from the range \(1\) to \(n\). One number in this range is missing. Your task is to find and output the missing number.

You can solve this problem by computing the expected sum of the first \(n\) natural numbers using the formula \(\frac{n(n+1)}{2}\) and then subtracting the actual sum of the given numbers.

inputFormat

The input consists of two lines:

  • The first line contains an integer \(k\), which represents the number of elements provided in the array.
  • The second line contains \(k\) space-separated integers.

Note that \(n = k + 1\) because exactly one number in the range \(1\) to \(n\) is missing.

outputFormat

Output a single integer — the missing number from the range \(1\) to \(k+1\).

## sample
4
1 2 4 5
3