#K41177. Smallest Missing Positive Integer

    ID: 26808 Type: Default 1000ms 256MiB

Smallest Missing Positive Integer

Smallest Missing Positive Integer

You are given an unsorted array of integers. Your task is to find the smallest positive integer that does not appear in the array.

The problem is designed to test your ability to manage arrays and implement an efficient algorithm. Consider the following examples:

  • For the array [1, 2, 0], the answer is 3.
  • For the array [3, 4, -1, 1], the answer is 2.
  • For the array [7, 8, 9, 11, 12], the answer is 1.

Note that your solution should read from the standard input and write to the standard output.

inputFormat

The first line contains a single integer n — the number of elements in the array.

The second line contains n space-separated integers.

outputFormat

Output a single integer — the smallest positive integer that is missing from the array.

## sample
3
1 2 0
3

</p>