#K11271. Find the Missing Train

    ID: 23432 Type: Default 1000ms 256MiB

Find the Missing Train

Find the Missing Train

You are given a number \(n\) which represents the total number of distinct trains numbered from 1 to \(n\). In each test case, you are also provided with a list of observed train numbers. Your task is to determine the smallest missing train number from the observed list.

If all trains numbered from 1 to \(n\) are observed, output NO MISSING TRAIN. Otherwise, output the smallest number in the range \(1 \ldots n\) that is not in the list.

Example: For \(n = 5\) and observed trains [1, 2, 4, 5], the missing train is 3.

inputFormat

The input consists of multiple test cases. For each test case, the first line contains an integer \(n\) (the total number of trains). The second line contains \(n'\) space-separated integers representing the observed train numbers (where \(n'\) is less than or equal to \(n\)). The input is terminated by a test case where \(n = 0\), which should not be processed.

Note: The input is provided through stdin.

outputFormat

For each test case, print the smallest missing train number on a separate line. If no train is missing (i.e. all numbers from 1 to \(n\) appear), print NO MISSING TRAIN instead.

The output is expected to be written to stdout.

## sample
5
1 2 4 5
6
2 3 5 6 1
0
3

4

</p>