| 2018 UBC Winter Contest 3 |
|---|
| Finished |
Faul decided to become a farmer, and he grows bamboo!
Faul has n bamboo stalks numbered from 1 to n, and he can do three operations on them. He can cut and harvest all of the bamboo at a certain height, order a single bamboo stalk to grow, or use magic to make all bamboo stalks grow.
Faul knows exactly what his next q operations will be. Each operation will be one of the three types.
Since Faul has more important things to tend to (such as badminton), he wants you to help him predict the amount of bamboo he will harvest after each cut.
The first line of input contains two space-separated integers n and q (1 ≤ n ≤ 106;1 ≤ q ≤ 106).
The second line of input contains n space-separated integers hi (1 ≤ hi ≤ 106), where hi is the initial height of the ith bamboo stalk.
Each of the next q lines contains a query. Each query is one of the three aforementioned types.
For each CUT query, output a single integer, on a line by itself, that is the total length of bamboo harvested by that cut.
4 5
1 2 3 3
GROW 3 1
CUT 2
MAGIC 2
CUT 2
CUT 7
3
7
0
In the first sample, we do the following.
| Name |
|---|


