#C12281. Find the Missing Number

    ID: 41691 Type: Default 1000ms 256MiB

Find the Missing Number

Find the Missing Number

You are given a list of unique integers that are in the range from 1 to (n) (inclusive), but with exactly one missing number. Using the well-known formula for the sum of the first (n) natural numbers, (\frac{n(n+1)}{2}), determine the missing number in the sequence.

For example, if the input array is [1, 2, 4, 5] then the missing number is 3.

inputFormat

Input is read from standard input (stdin).

The first line contains an integer (k), representing the number of elements provided in the list. The second line contains (k) space-separated integers. Note that the full range should be from 1 to (n), where (n = k + 1).

outputFormat

Output the missing number as a single integer to standard output (stdout).## sample

4
1 2 4 5
3

</p>