Find Smallest Positive MissingEasy

Find Smallest Positive Missing

EasyPractice library · +10 XPheapsarrayssorting

Given a list of integers, find the smallest positive integer (greater than 0) that is not present in the list.

For example, if the list is [1, 3, 6, 4, 1, 2], the smallest positive missing integer is 5. If the list is [-1, -3], the smallest positive missing integer is 1. If the list is [1, 2, 3], the smallest positive missing integer is 4.

Input

The first line contains an integer N, the number of elements in the list. The second line contains N space-separated integers.

Output

Print a single integer: the smallest positive integer not present in the list.

Constraints

1 <= N <= 1000. The integers in the list are between -10^9 and 10^9.

Time limit 1 s (native code; slower languages get more)Memory 256 MB14 hidden tests

Example 1

Input
6
1 3 6 4 1 2
Output
5

The positive numbers are 1, 3, 6, 4, 1, 2. The unique positives are 1, 2, 3, 4, 6. The smallest missing positive integer is 5.

Example 2

Input
3
-1 -3 -5
Output
1

There are no positive integers in the list. The smallest positive integer is 1.

Hints