#K71277. Smallest Missing Positive Integer

    ID: 33496 Type: Default 1000ms 256MiB

Smallest Missing Positive Integer

Smallest Missing Positive Integer

You are given an array \(A\) of \(N\) integers. Your task is to find the smallest positive integer that does not appear in \(A\). In other words, find the minimum integer \(x\) (with \(x \ge 1\)) such that \(x \notin A\).

Note: The solution should work efficiently even for large input sizes. Use appropriate data structures where necessary.

inputFormat

The input consists of two lines:

  • The first line contains an integer \(N\), which represents the number of elements in the array \(A\).
  • The second line contains \(N\) space-separated integers representing the elements of \(A\).

outputFormat

Output a single integer representing the smallest missing positive integer from the array \(A\).

## sample
5
2 3 4 1 6
5

</p>