Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

2891.   "Sub"-Sequence
Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 2524   Accepted Runs: 1485

Given a sequence which contains n elements, we can get its "Sub"-sequence by taking the difference between each pair of adjacent elements. For instance, the original sequence is a1, a2... an, and its "Sub"-sequence is b1, b2... bn-1, where bi = ai+1 - ai.

Now we iteratively apply the above process several times until there is only one element in the sequence. Please write a program to calculate the last element left in the "Sub"-sequence.


There are several test cases in the input data. The first line contains the number of test cases. There are two lines in each test case. The first line contains a positive integer N (1 ≤ N ≤ 20) denoting the length of the original sequence. The second line contains a sequence of N elements separated by spaces. It is guaranteed that the absolute value of every element will not exceed 100.


Output the last element left in the "Sub"-sequence in one line for every test case.

Sample input:

1 2 3 4
12 -5 3 -100 8

Sample output:


Source: TJU Exam 2007
Submit   List    Runs   Forum   Statistics

Tianjin University Online Judge v1.3.0
Maintance:Fxz. Developer: SuperHacker, G.D.Retop, Fxz