#C3915. Find the Missing Book ID
Find the Missing Book ID
Find the Missing Book ID
You are given a total number of books n that are sequentially numbered from 1 to n. However, one of the book IDs is missing from the records. You are provided with a list of n - 1 logged book IDs. Your task is to find the missing book ID.
You can use the formula for the sum of the first n natural numbers, which is given by:
\( \frac{n(n+1)}{2} \)
Subtract the sum of the logged book IDs from this total sum to determine the missing ID.
inputFormat
The input is read from stdin and follows the format below:
- The first line contains an integer T, the number of test cases.
- For each test case:
- The first line contains the integer n, representing the total number of books.
- The second line contains n - 1 space-separated integers which are the logged book IDs. If there are no logged IDs, the line will be empty.
outputFormat
For each test case, output a single integer on a new line which represents the missing book ID. The output is printed to stdout.
## sample2
5
1 2 3 5
4
3 1 4
4
2
</p>