CF1877A.Goals of Victory

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Goals of Victory

There are nn teams in a football tournament. Each pair of teams match up once. After every match, Pak Chanek receives two integers as the result of the match, the number of goals the two teams score during the match. The efficiency of a team is equal to the total number of goals the team scores in each of its matches minus the total number of goals scored by the opponent in each of its matches.

After the tournament ends, Pak Dengklek counts the efficiency of every team. Turns out that he forgot about the efficiency of one of the teams. Given the efficiency of n1n-1 teams a1,a2,a3,,an1a_1,a_2,a_3,\ldots,a_{n-1}. What is the efficiency of the missing team? It can be shown that the efficiency of the missing team can be uniquely determined.

Input

Each test contains multiple test cases. The first line contains an integer tt (1t5001 \leq t \leq 500) — the number of test cases. The following lines contain the description of each test case.

The first line contains a single integer nn (2n1002 \leq n \leq 100) — the number of teams.

The second line contains n1n-1 integers a1,a2,a3,,an1a_1,a_2,a_3,\ldots,a_{n-1} (100ai100-100\leq a_i\leq100) — the efficiency of n1n-1 teams.

Output

For each test case, output a line containing an integer representing the efficiency of the missing team.

Note

In the first test case, below is a possible tournament result:

  • Team 11 vs. Team 22: 121-2
  • Team 11 vs. Team 33: 303-0
  • Team 11 vs. Team 44: 323-2
  • Team 22 vs. Team 33: 141-4
  • Team 22 vs. Team 44: 131-3
  • Team 33 vs. Team 44: 505-0

The efficiency of each team is:

  1. Team 11: (1+3+3)(2+0+2)=74=3(1+3+3)-(2+0+2)=7-4=3
  2. Team 22: (2+1+1)(1+4+3)=48=4(2+1+1)-(1+4+3)=4-8=-4
  3. Team 33: (0+4+5)(3+1+0)=94=5(0+4+5)-(3+1+0)=9-4=5
  4. Team 44: (2+3+0)(3+1+5)=59=4(2+3+0)-(3+1+5)=5-9=-4

Therefore, the efficiency of the missing team (team 44) is 4-4.

It can be shown that any possible tournament of 44 teams that has the efficiency of 33 teams be 33, 4-4, and 55 will always have the efficiency of the 44-th team be 4-4.

Samples

2
4
3 -4 5
11
-30 12 -57 7 0 -81 -68 41 -89 0
-4
265

在线编程 IDE

建议全屏模式获得最佳体验