#C10297. Smallest Missing Prime Number
Smallest Missing Prime Number
Smallest Missing Prime Number
You are given a list of integers. Your task is to find the smallest missing prime number from the list. In other words, if we denote the set of prime numbers by \(\mathbb{P}\), you should find the smallest \(p \in \mathbb{P}\) such that \(p\) does not appear in the input.
If all prime numbers up to the maximum number in the list are present, then you must output the next prime number greater than the maximum value in the list.
Note: The list may be empty or contain non-prime numbers. In the case of an empty list, the answer is \(2\), which is the smallest prime number. For clarity, the prime sequence starts as: \(2, 3, 5, 7, \ldots\).
Example: For the list [2, 3, 5, 7, 11, 13, 17], since all primes up to 17 are present, the answer is 19.
inputFormat
The first line contains a single integer \(n\) representing the number of elements in the list. If \(n = 0\), the list is empty.
The second line contains \(n\) space-separated integers representing the elements of the list.
outputFormat
Output a single integer, which is the smallest missing prime number based on the above description.
## sample7
2 3 5 7 11 13 17
19