14253 - 2024_IDS_Spring_Assignment1_Undo_Calculator   

Description

You have a magical calculator that can undo operations you don't want. This calculator supports the following three operations:

- + x: Add x to the current result.

- - x: Subtract x from the current result.

- Undo: Undo the previous addition or subtraction operation. If there was no previous addition or subtraction, no action is taken.

please ouput the result of the calculator after n operation.

The calculator starts the calculation from 0.

Input

the first line contain one integer n.

the next n lines, each line contain one of the 3 operations.

- 1 ≤ n ≤ 2 * 106

- 1 ≤ x ≤ 100

Output

Output the result of the calculator.

Remember to print a ‘\n’ at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss