Missing Shipment ID
Easy1s time · 256MB memory · arrays, math
The logistics company SwiftShip assigns shipment IDs starting from 1 in increasing order. Due to a synchronization issue, exactly one shipment ID is missing from the database. Given all recorded shipment IDs, determine which one is missing.
Input
The first line contains one integer n — the number of recorded shipment IDs.
The second line contains n distinct integers a₁ … aₙ — the recorded IDs.
Output
Print the missing shipment ID.
Constraints
- 1 ≤ n ≤ 2·10⁴
- 1 ≤ aᵢ ≤ n + 1
- All recorded IDs are distinct; exactly one ID from 1 to n + 1 is missing.
Samples
Input 1
5 1 2 3 5 6
Output 1
4
Input 2
3 1 2 4
Output 2
3
Sign in (top right) to run or submit.