1. First missing positive roll number
hardStudents of a class of n type their roll numbers into a lab sheet. Some typed wrong values: zero, negative numbers, repeated numbers or numbers far too large.
Print the smallest positive roll number, starting from 1, that does not appear in the list. Your program should run in O(n) time and use only a few variables besides the array of numbers.
Input: The first line has one integer n. The second line has n integers: the numbers typed into the sheet.
Output: One integer: the smallest positive number that is missing.
Limits: 1 ≤ n ≤ 10^5 · -10^9 ≤ number ≤ 10^9
Example 1
Input
5 3 4 -1 1 9
Output
2
1 is present but 2 is not.
Example 2
Input
4 2 1 4 3
Output
5
1 to 4 are all present, so the answer is 5.