#C7831. Find the Missing Element
Find the Missing Element
Find the Missing Element
Given a list of unique integers which contains all numbers in the range \(1\) to \(n\) except for one missing number, your task is to find and output the missing number.
The input consists of two lines. The first line contains a single integer \(n\) indicating the total number of integers from \(1\) to \(n\). The second line contains \(n-1\) distinct integers separated by spaces, representing the numbers present in the array. It is guaranteed that exactly one number in the range \(1\) to \(n\) is missing.
You can solve this problem using the formula for the sum of the first \(n\) natural numbers \(\left(\frac{n(n+1)}{2}\right)\) and then subtracting the sum of the provided numbers to find which number is missing.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer \(n\) representing the size of the complete sequence \(\{1, 2, ..., n\}\).
- The second line contains \(n-1\) space-separated integers which are the elements of the array.
outputFormat
Output the missing integer to standard output (stdout).
## sample8
3 7 1 2 8 4 5
6
</p>