For an empty set S, given q queries, where each query is an integer x:
- 1xa: Insert a elements with value x into the set.
- 2xb: Remove b elements with value x from the set. If the number of elements with value x in the set is less than b, remove all elements with value x.
- 3: Find the minimum value in the set.
- 4: Find the maximum value in the set.
- 5y: Let x be the maximum value less than y in the set, and z be the minimum value greater than y in the set. Calculate the sum of elements with values x or y or z. If there is no satisfied x,y or z, you can ignore them.
The set S may contain multiple elements with the same value.
### Input
- The first line contains an integer q.
- The next q lines, each containing a query in the specified format.
### Output
- For each query of types 3,4,5, print an integer as the answer.
### Constraints
- 1≤q≤105.
- 1≤x,a,b,y≤106.
### Example
Input
8113122513212134452
Output:
71317