Big Integer

Statement

Nathan is a big fan of recreational mathematics. For one of his problems, he needs to add together very large numbers. He created a class called BigInteger to help with the adding, but he isn't done yet! Nathan needs to stress test his code, so he devised the following problem.

There will be N instructions (which are given as a string of length N). There are two types of instructions:

  • 0 to 9: Add this digit to the end of the current number. Afterwards, add the current number to the total
  • - : Remove the last digit from the current number. It is guaranteed that the current number will not be empty after this instruction. Afterwards, add the current number to the total.

At the beginning, the total is 0 and the current number is 0. Nathan wrote a program in Python to solve this problem, but it is slow and drains his battery too much. Can you help Nathan double check his answers?

Input

The first line will contain the integer N (N ≤ 500 000). The second line will contain a string of length N. Every character in this string can be found in 0123456789-.

Output

Print the total. Leading zeroes will be ignored by the checker.

Example input 1
8
0100---5
	
Example output 1
00000127
	
Explanation 1
00 + 001 + 0010 + 00100 + 0010 + 001 + 00 + 005 = 127
    
Example input 2
4
1817
	
Example output 2
2017
	
Explanation 2
01 + 018 + 0181 + 01817 = 2017
    
Example input 3
2
0-
	
Example output 3
00
	
Time and memory limit:

  • 7 seconds
  • 256MB

Problem source: DMOJ