DWITE Online Computer Programming Contest

That Missing Number

October 2009
Problem 3

You have a consecutive sequence of unique numbers, 1 to N, that you like very much, but your little sister always steals one (and only one), and randomly rearranges the rest in an attempt to hide the crime. Given N−1 numbers, in a random order, find out which number was taken.

The input file DATA3.txt will contain 5 sets of input. The first line will be an integer 1 ≤ M ≤ 100, the number of items remaining. This is followed by M lines of unique integers, from at least 1 to at most M+1.

The output file OUT3.txt will contain 5 lines, each being the integer missing from the set.

Note: The original sorted sequence is {1, 2, 3,..., N−1, N}. Any of the numbers (including 1 or N) can be taken.

Sample Input (first 3 of 5 shown):
2
1
2
2
2
3
2
1
3
Sample Output (first 3 of 5 shown):
3
1
2