A. [Atc349A] Zero Sum Game

    传统题 1000ms 256MiB

[Atc349A] Zero Sum Game

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

There are NN people labeled 11 to NN, who have played several one-on-one games without draws. Initially, each person started with 00 points. In each game, the winner's score increased by 11 and the loser's score decreased by 11 (scores can become negative). Determine the final score of person NN if the final score of person ii (1iN1)(1 \leq i \leq N-1) is AiA_i. It can be shown that the final score of person NN is uniquely determined regardless of the sequence of games.

Input

The input consists of:

  • A single integer NN (2N100)(2 \leq N \leq 100) — the number of people.
  • A list of N1N-1 integers A1,A2,,AN1A_1, A_2, \ldots, A_{N-1} (100Ai100)(-100 \leq A_i \leq 100) — the final scores of persons 11 to N1N-1.

Output

Print the final score of person NN.

Example

Input 1

4
1 2 -1
2

Explanation

Here is one possible sequence of games where the final scores of persons 1,2,31, 2, 3 are 1,2,11, -2, -1, respectively. Initially, persons 1,2,3,41, 2, 3, 4 have 0,0,0,00, 0, 0, 0 points, respectively.

  1. Persons 11 and 22 play, and person 11 wins. The players now have 1,1,0,01, -1, 0, 0 points.
  2. Persons 11 and 44 play, and person 44 wins. The players now have 0,1,0,10, -1, 0, 1 points.
  3. Persons 11 and 22 play, and person 11 wins. The players now have 1,2,0,11, -2, 0, 1 points.
  4. Persons 22 and 33 play, and person 22 wins. The players now have 1,1,1,11, -1, -1, 1 points.
  5. Persons 22 and 44 play, and person 44 wins. The players now have 1,2,1,21, -2, -1, 2 points.

In this case, the final score of person 44 is 22. Other possible sequences of games exist, but the score of person 44 will always be 22 regardless of the progression.

3
0 0
0
6
10 20 30 40 50
-150

Programming exercise on 14 August

未参加
状态
已结束
规则
XCPC
题目
3
开始于
2024-8-14 16:30
结束于
2024-8-14 18:30
持续时间
2 小时
主持人
参赛人数
2