#C13572. Find Missing Numbers
Find Missing Numbers
Find Missing Numbers
You are given a list of integers which is a subset of the first n natural numbers (i.e. \(1,2,\ldots,n\)) in increasing order. However, some numbers in the range may be missing. Your task is to find and output the missing numbers in ascending order.
The value of \(n\) is not given explicitly. Instead, it can be determined using the following relationship:
[ n = \text{length}(\text{array}) + \left|{ i \mid 1 \le i \le \text{length}(\text{array}) \text{ and } i \notin \text{array} }\right| ]
For example:
- Input:
1 3 5 6 7
(where the first number indicates the count, i.e. 5 numbers are provided) results in \(n = 7\) and the missing numbers are2 4
. - Input:
1 2 3 4 5
results in no missing number.
You must read the input from standard input and output the result to standard output. If there are no missing numbers, output an empty line.
inputFormat
The input is given via standard input. The first line contains a single integer \(n\) — the number of elements in the list. The second line contains \(n\) space-separated integers representing the list.
If \(n = 0\), the second line may be empty.
outputFormat
Output a single line containing the missing numbers in ascending order, separated by a single space. If there are no missing numbers, output an empty line.
## sample5
1 3 5 6 7
2 4