#C11610. Smallest Missing Positive Integer

    ID: 40946 Type: Default 1000ms 256MiB

Smallest Missing Positive Integer

Smallest Missing Positive Integer

Given an array of integers that may include both positive and negative numbers, your task is to find the smallest positive integer that does not appear in the array.

For example, consider the array \( [1, 3, 6, 4, 1, 2] \). The smallest positive integer missing from this array is \( 5 \). This problem requires you to consider only positive numbers and ignore any negative values.

The input will be provided via standard input (stdin) and the output must be printed to standard output (stdout).

Note: Use \( \LaTeX \) format for any mathematical formulae.

inputFormat

The input consists of two lines. The first line is an integer \( n \) indicating the number of elements in the array. The second line contains \( n \) space-separated integers.

Example:

6
1 3 6 4 1 2

outputFormat

Output a single integer representing the smallest positive integer that is not present in the array.

Example:

5
## sample
6
1 3 6 4 1 2
5