Missing Number
Published in
Jul 7, 2022
You are given all numbers between 1,2,…,n1,2,…,n except one. Your task is to find the missing number.
Input
The first input line contains an integer nn.
The second line contains n−1n−1 numbers. Each number is distinct and between 11 and nn (inclusive).
Output
Print the missing number.
Constraints
- 2≤n≤2⋅1052≤n≤2⋅105
Example
Input:5
2 3 1 5
Output:4
To solve this problem, you should aware of formula to sum 1 to n. Sum of n number is (n)(n+1) / 2.