Type: Default 1000ms 256MiB

速通大赛

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

藤藤正在玩一个Game,已知这个Game主角有一个HpHp值, 且HpHp没有上限,但当Play过程中任意时刻一旦HpHp小于等于零、则Game会结束。

已知该Game共有 nn 的回合,第 ii 个回合有一个参数 aia_i

ai>0a_i > 0 时表示藤藤在通过该回合时,会增加 aia_i 点生命值;

ai<0a_i < 0 时表示藤藤在通过该回合时,会减少 aia_i 点生命值;

ai=0a_i = 0 时表示藤藤在通过该回合时,不会有HpHp的改变。

请问藤藤最少在初始时最少需要拥有多少HpHp,才能顺利通过所有回合? 注意结束时藤藤的Hp值也不能小于等于零

Format

Input

输入共两行

第一行一个正整数表示关卡数 nn

第二行 nn 个整数,表示 a1,a2,a3,ana_1, a_2, a_3 \dots, a_n

Output

输出共一行一个整数表示答案

Samples

样例输入 1

3
4 -7 2

样例输出 1

4

样例输入 2

3
1 0 1

样例输出 2

1

样例解释 2

初始时如果HpHp为0, 就没开始就挂了

Limitation

对于 30%30\% 的数据,1n201 \leq n \leq 20

对于 60%60\% 的数据,1n1031 \leq n \leq 10^3

对于 100%100\% 的数据,1n105,103ai1031 \leq n \leq 10^5, -10^3 \leq a_i \leq 10^3

20250220周赛

Not Attended
Status
Done
Rule
IOI
Problem
7
Start at
2025-2-20 16:30
End at
2025-2-20 18:30
Duration
2 hour(s)
Host
Partic.
26