#K50747. Find the First Missing Positive Integer

    ID: 28933 Type: Default 1000ms 256MiB

Find the First Missing Positive Integer

Find the First Missing Positive Integer

You are given an unsorted array of positive integers. Your task is to find the smallest positive integer that is missing from the array. In other words, you need to determine the first missing integer in the sequence starting from 1. If all integers from 1 to \(n\) (where \(n\) is the number of elements in the array) are present, then the answer is \(n+1\).

Example:

Input: [2, 3, 4]
Output: 1

Input: [1, 2, 4, 6, 3, 7, 8] Output: 5

Input: [1, 2, 3, 4, 5] Output: 6

</p>

The solution should read from standard input and output the answer to standard output.

inputFormat

The first line of input contains a single integer \(n\), representing the number of elements in the array. The next line contains \(n\) space-separated positive integers.

outputFormat

Output a single integer which is the first missing positive integer from the array.

## sample
3
2 3 4
1

</p>