#C10811. Find Missing Number in Arithmetic Progression

    ID: 40058 Type: Default 1000ms 256MiB

Find Missing Number in Arithmetic Progression

Find Missing Number in Arithmetic Progression

You are given an array that represents an arithmetic progression with exactly one missing element. The full arithmetic progression should contain n numbers, but the provided array contains only n - 1 numbers. Use the formula for the sum of an arithmetic progression: $$S = \frac{n(a_1 + a_n)}{2}$$ to determine the missing number.

For example, given the array [2, 4, 8, 10], the missing number is 6.

inputFormat

The first line contains an integer T denoting the number of test cases. Each test case starts with an integer k representing the number of given elements, followed by k space-separated integers which form the arithmetic progression with one missing element.

outputFormat

For each test case, output the missing number on a separate line.

## sample
5
4 2 4 8 10
3 1 7 10
3 3 9 12
4 5 10 20 25
3 5 15 20
6

4 6 15 10

</p>