#K42202. Missing Task in Task Sequence

    ID: 27035 Type: Default 1000ms 256MiB

Missing Task in Task Sequence

Missing Task in Task Sequence

You are given a series of datasets. For each dataset, you are provided with:

  • An integer base representing the starting task code.
  • An integer n representing the total number of consecutive tasks.
  • A list of n - 1 observed task codes that are all present in the full sequence.

The complete sequence for a dataset is given by $$[\text{base},\,\text{base}+1,\,\ldots,\,\text{base}+n-1]$$. Exactly one task code is missing from the observed list. Your task is to find that missing task code for each dataset.

The input terminates with a dataset where both base and n are 0. This terminating dataset should not be processed.

Example: If the dataset is given by:

5 5
5 6 7 9

The full sequence is 5, 6, 7, 8, 9 and the missing code is 8.

inputFormat

The input consists of multiple datasets. Each dataset has the following format:

  1. A line containing two integers: base and n (the total number of tasks).
  2. A line containing n - 1 space-separated integers representing the observed task codes.

The input terminates with a line containing "0 0", which should not be processed.

All values are provided via standard input (stdin).

outputFormat

For each dataset, output the missing task code on a separate line. The result should be written to standard output (stdout).

## sample
5 5
5 6 7 9
20 4
20 21 23
50 3
50 52
0 0
8

22 51

</p>