#K57962. Find Missing Positive Integer

    ID: 30537 Type: Default 1000ms 256MiB

Find Missing Positive Integer

Find Missing Positive Integer

You are given a list of integers that may contain both positive and negative values. Your task is to find the smallest positive integer (x) such that (x > 0) and (x) does not appear in the list. The list is unsorted and may include duplicates.

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

inputFormat

The input is given via standard input. The first line contains an integer (n) representing the number of elements in the list. The second line contains (n) space-separated integers. If (n = 0), the second line will be empty.

outputFormat

Output the smallest missing positive integer to the standard output.## sample

4
3 4 -1 1
2

</p>