#C1928. Find the Missing Number

    ID: 45187 Type: Default 1000ms 256MiB

Find the Missing Number

Find the Missing Number

You are given two inputs. The first input is an integer n representing the upper bound of the range \(1, 2, \dots, n\). The second input is a sequence of n-1 space-separated integers which include each number from 1 to n except one.

Your task is to determine the missing number in the sequence. The problem can be mathematically represented using the formula for the sum of the first \(n\) natural numbers:

[ S = \frac{n(n+1)}{2} ]

If you subtract the sum of the provided numbers from \(S\), you will obtain the missing number.

Make sure your solution reads input from stdin and writes output to stdout.

inputFormat

The input consists of two lines. The first line contains a single integer n ((2 \leq n \leq 10^5)) representing the range [1, n]. The second line contains n-1 space-separated integers representing the list missing exactly one number.

outputFormat

Output a single integer which is the missing number in the range.## sample

5
1 2 3 5
4