

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 100 点
問題文
1 から N の番号が付けられた N 人の人がおり、この中で一対一の勝敗のつくゲームを何度か行いました。N 人は最初にそれぞれ持ち点として 0 を持っており、各ゲームでは勝者の持ち点が 1 増え、敗者の持ち点が 1 減ります(持ち点が負になることもあります)。最終的に人 i\ (1\leq i\leq N-1) の持ち点が A_i になったとき、人 N の持ち点を求めてください。なお、ゲームの進行によらず最終的な人 N の持ち点は一意に定まることが示せます。
制約
- 2\leq N\leq 100
- -100\leq A_i\leq 100
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_{N-1}
出力
答えを出力せよ。
入力例 1
4 1 -2 -1
出力例 1
2
最終的に人 1,2,3 の持ち点が 1,-2,-1 となるような進行として、例えば次のようなものが考えられます。
- 最初、人 1,2,3,4 の持ち点はそれぞれ 0,0,0,0 である。
- 人 1 と 2 が対戦して、人 1 が勝利する。4 人の持ち点はそれぞれ 1,-1,0,0 である。
- 人 1 と 4 が対戦して、人 4 が勝利する。4 人の持ち点はそれぞれ 0,-1,0,1 である。
- 人 1 と 2 が対戦して、人 1 が勝利する。4 人の持ち点はそれぞれ 1,-2,0,1 である。
- 人 2 と 3 が対戦して、人 2 が勝利する。4 人の持ち点はそれぞれ 1,-1,-1,1 である。
- 人 2 と 4 が対戦して、人 4 が勝利する。4 人の持ち点はそれぞれ 1,-2,-1,2 である。
この場合、人 4 の持ち点は 2 になります。ほかにも別の進行が考えられますが、どのような進行であっても人 4 の持ち点は 2 になります。
入力例 2
3 0 0
出力例 2
0
入力例 3
6 10 20 30 40 50
出力例 3
-150
Score: 100 points
Problem Statement
There are N people labeled 1 to N, who have played several one-on-one games without draws. Initially, each person started with 0 points. In each game, the winner's score increased by 1 and the loser's score decreased by 1 (scores can become negative). Determine the final score of person N if the final score of person i\ (1\leq i\leq N-1) is A_i. It can be shown that the final score of person N is uniquely determined regardless of the sequence of games.
Constraints
- 2 \leq N \leq 100
- -100 \leq A_i \leq 100
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_{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, 3 are 1, -2, -1, respectively.
- Initially, persons 1, 2, 3, 4 have 0, 0, 0, 0 points, respectively.
- Persons 1 and 2 play, and person 1 wins. The players now have 1, -1, 0, 0 point(s).
- Persons 1 and 4 play, and person 4 wins. The players now have 0, -1, 0, 1 point(s).
- Persons 1 and 2 play, and person 1 wins. The players now have 1, -2, 0, 1 point(s).
- Persons 2 and 3 play, and person 2 wins. The players now have 1, -1, -1, 1 point(s).
- Persons 2 and 4 play, and person 4 wins. The players now have 1, -2, -1, 2 point(s).
In this case, the final score of person 4 is 2. Other possible sequences of games exist, but the score of person 4 will always be 2 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