#K9851. Find the Missing Number

    ID: 39121 Type: Default 1000ms 256MiB

Find the Missing Number

Find the Missing Number

Given an integer \( n \) and a sequence of \( n-1 \) distinct integers from 1 to \( n \), the task is to find the missing number in this range. The missing number can be computed using the formula for the sum of the first \( n \) natural numbers:

\( S = \frac{n(n+1)}{2} \)

Subtracting the sum of the provided sequence from \( S \) yields the missing number.

You are given multiple test cases. For each test case, the first number in the input line is \( n \), followed by \( n-1 \) integers representing the sequence. You need to output the missing number for each test case on a new line.

inputFormat

The input is given via standard input (stdin) and has the following format:

  • The first line contains an integer \( T \) representing the number of test cases.
  • Each of the next \( T \) lines starts with an integer \( n \) (where \( n \geq 2 \)) followed by \( n-1 \) space separated integers representing a sequence of distinct numbers from 1 to \( n \) with one missing number.

outputFormat

For each test case, output the missing number on a new line to standard output (stdout).

## sample
2
5 1 2 3 5
3 1 3
4

2

</p>