St Andrews Online Judge

Collect Coins

By Kay Akashi

Time: 1000 ms
Memory: 256000 kB

The code judging system is only available during contests. Check out the github repo for test cases and solutions.

Please log in.

Problem Statement

You're playing a game that is composed of nn rounds. Before starting a game, you have 00 coin. In ii-th round, you earn A[i]A[i] coins. However, the maximum number of coins you can have is 1010 and minimum is 00 (i.e.i.e. you will not have more than 1010 coins, and you will not have less than 00 coin). What is the resulting number of coins you have after finishing all nn rounds?

Note that, A[i]A[i] can be negative: in this case, you lose A[i]A[i] coins rather than earning them.

Constraints

0n<1050 \leq n \lt 10^{5}, 5A[i]5-5 \leq A[i] \leq 5.

Input

The first line of input contains one integer, nn. The second line of input contains nn integers, A[i]A[i].

Output

Output the answer.

Examples

Input

4
3 5 5 -3

Output

7

Explanation

The numbers of coins you have after finishing each round are as follows: 33, 88, 1010, and 77, hence the answer is 77.

Input

3
2 -4 -4

Output

0

Explanation

The numbers of coins you have after finishing each round are as follows: 22, 00, and 00 hence the answer is 00.