#K91342. Find the Smallest Missing Positive Integer

    ID: 37954 Type: Default 1000ms 256MiB

Find the Smallest Missing Positive Integer

Find the Smallest Missing Positive Integer

You are given an integer n and a list of n integers. Your task is to find the smallest missing positive integer from the list. Formally, given a list \(A = [a_1, a_2, \dots, a_n]\), determine the smallest positive integer \(x\) such that \(x \notin A\). This problem tests your ability to work with arrays and apply set-based reasoning.

inputFormat

The input is read from stdin in the following format:

  • The first line contains a single integer n representing the number of elements in the list.
  • The second line contains n space-separated integers.

It is guaranteed that the list may contain negative numbers, zeros, and repeated values.

outputFormat

Output the smallest missing positive integer to stdout.

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