#K9371. Smallest Missing Positive Integer

    ID: 38480 Type: Default 1000ms 256MiB

Smallest Missing Positive Integer

Smallest Missing Positive Integer

You are given a list of n integers. Your task is to determine the smallest positive integer that does not appear in the list.

Formally, if the list contains some positive integers, find the smallest integer k (> 0) such that

\( k \notin \{a_1, a_2, \dots, a_n\} \)

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

Note: The input is provided via standard input and the output should be written to standard output.

inputFormat

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

outputFormat

Output a single integer — the smallest positive integer that does not appear in the given list.

## sample
5
3 4 -1 1 2
5