## Problem S1: Zero That Out

Fortunately, your boss realizes when an incorrect number is read and says "zero", meaning "ignore the current last number."

Unfortunately, your boss can make repeated mistakes, and says "zero" for each mistake.

For example, your boss may say "One, three, five, four, zero, zero, seven, zero, zero, six", which means the total is 7 as explained in the following chart:

Boss statement(s)Current numbersExplanation
"One, three, five, four"1, 3, 5, 4Record the first four numbers.
"zero, zero"1, 3Ignore the last two numbers.
"seven"1, 3, 7Record the number 7 at the end of our list.
"zero, zero"1Ignore the last two numbers.
"six"1, 6We have read all numbers, and the total is 7.

At any point, your boss will have said at least as many positive numbers as "zero" statements. If all positive numbers have been ignored, the sum is zero.

Write a program that reads the sequence of boss statements and computes the correct sum.

### Input

The first line of input contains the integer K (1 ≤ K ≤ 100 000) which is the number of integers (including "zero") your boss will say. On each of the next K lines, there will be either one integer between 1 and 100 (inclusive), or the integer 0.

### Output

The output is one line, containing the integer which is the correct sum of the integers read, taking the "zero" statements into consideration. You can assume that the output will be an integer in the range 0 and 1 000 000 (inclusive).

```4
3
0
4
0
```

```0
```

```10
1
3
5
4
0
0
7
0
0
6
```

### Sample Output 2

```7
```

Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

• (0/0)
Why is my solution taking too long?

• (0/0)
Your code executes in O(k^2) time, which is too slow for k = 100 000. Try a different approach.

• (0/0)
You might want to look up what a "stack" is

• (0/0)
What if the first number is zero?

• (0/0)
I think you can assume all the operations are valid.