#K16261. Missing Positive Integer
Missing Positive Integer
Missing Positive Integer
Given a list of integers, your task is to determine the smallest positive integer that does not appear in the list.
Formally, let \(A\) be the input list. You need to find the smallest integer \(k\) (where \(k \ge 1\)) such that \(k \notin A\). For example, if \(A = [3, 4, -1, 1]\), the answer is \(2\), because \(1\) is present but \(2\) is missing.
The problem requires reading input from standard input and writing the output to standard output.
inputFormat
The input is given via standard input (stdin) with the following format:
- 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\), it indicates that the list is empty.
outputFormat
Output a single integer representing the smallest positive integer that is not present in the list. The output should be written to standard output (stdout).
## sample4
3 4 -1 1
2