#abc349a. A - Zero Sum Game

A - Zero Sum Game

Score: 100100 points

问题陈述

NN 个人,编号为 11NN,他们进行了几场一对一的比赛,没有平局。最初,每个人的得分都是 00。在每场比赛中,胜者的得分增加 11,而败者的得分减少 11(得分可以变成负数)。如果第 ii 个人的最终得分是 Ai (1iN1)A_i\ (1\leq i\leq N-1),请确定第 NN 个人的最终得分。可以证明,无论比赛的顺序如何,第 NN 个人的最终得分都是唯一确定的。

以上为大语言模型 kimi 翻译,仅供参考。

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 i (1iN1)i\ (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.

Constraints

  • 2N1002 \leq N \leq 100
  • 100Ai100-100 \leq A_i \leq 100
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \ldots AN1A_{N-1}

Output

Print the answer.

Sample Input 1

4
1 -2 -1

Sample Output 1

2

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.
  • Persons 11 and 22 play, and person 11 wins. The players now have 1,1,0,01, -1, 0, 0 point(s).
  • Persons 11 and 44 play, and person 44 wins. The players now have 0,1,0,10, -1, 0, 1 point(s).
  • Persons 11 and 22 play, and person 11 wins. The players now have 1,2,0,11, -2, 0, 1 point(s).
  • Persons 22 and 33 play, and person 22 wins. The players now have 1,1,1,11, -1, -1, 1 point(s).
  • Persons 22 and 44 play, and person 44 wins. The players now have 1,2,1,21, -2, -1, 2 point(s).

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.

Sample Input 2

3
0 0

Sample Output 2

0

Sample Input 3

6
10 20 30 40 50

Sample Output 3

-150