#CCBCHBA0000063. Missing Number (Missing Number)
Missing Number (Missing Number)
Missing Number
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
All numbers from 1 through n except exactly one are given. The n-1 supplied numbers are distinct and within [1,n]. Find the missing number.
Input
First line: n (2<=n<=200000). Second line: n-1 distinct integers in [1,n].
Output
Print the missing integer.
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): .
- Subtask 3 (50%): (đầy đủ miền CSES).
Examples
Example 1
Input:
5
2 3 1 5
Output:
4
Explanation:
The full sum is 15; the given numbers sum to 11, so the missing number is 4.
Example 2
Input:
2
2
Output:
1
Explanation:
Only 2 is given, so 1 is missing.