#K84312. Missing Number Problem
Missing Number Problem
Missing Number Problem
Given an array containing n distinct numbers from the range \([0, n]\), your task is to find the missing number.
In other words, the array is drawn from the set \(\{0, 1, 2, \dots, n\}\) with exactly one number missing. For example, if the array is [3, 0, 1], then even though the full set should be \(\{0,1,2,3\}\), the missing number is 2.
It is guaranteed that exactly one number in the range \([0,n]\) is missing. Use the formula for the sum of the first \(n\) natural numbers: \(S = \frac{n(n+1)}{2}\) and compare it to the sum of the given array.
inputFormat
The input consists of two lines. The first line contains a single integer n, representing the number of elements in the given array. The second line contains n space-separated integers representing the array elements.
outputFormat
Output a single integer representing the missing number from the array.
## sample3
3 0 1
2
</p>