#K94492. Find the Missing Number
Find the Missing Number
Find the Missing Number
Given an array of distinct positive integers, the array should contain all numbers from 1 to \(n\) except one missing number. The length of the array is \(n-1\). Your task is to find and output the missing number.
You can compute the missing number using the formula for the sum of the first \(n\) natural numbers:
$$S = \frac{n(n+1)}{2}$$
Then, subtract the sum of the given numbers from \(S\) to obtain the missing number.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer \(m\), the number of elements in the array.
- The second line contains \(m\) space-separated positive integers representing the array elements.
outputFormat
Output the missing number to standard output (stdout).
## sample5
1 2 4 5 6
3