#C281. Find the Missing Number in a Sequence

    ID: 46167 Type: Default 1000ms 256MiB

Find the Missing Number in a Sequence

Find the Missing Number in a Sequence

You are given a sequence of integers that represents a continuous range from 1 to n with exactly one number missing. Your task is to find the missing number. The complete sequence should sum up to \(\frac{n(n+1)}{2}\). Given the list of numbers (which is unsorted), you need to compute the missing value.

Note: The first input line gives the count of provided numbers, and the second line contains the list of space-separated integers. The missing number is computed as the difference between the expected sum of numbers from 1 to n and the actual sum of the provided list.

inputFormat

The input consists of two lines:

  1. The first line contains a single integer m, representing the number of integers provided (m = n - 1).
  2. The second line contains m space-separated integers, which are the numbers from the sequence with one missing number.

outputFormat

Output a single integer — the missing number from the complete sequence.## sample

5
1 2 4 5 6
3

</p>