People in southern Sweden are known to eat falafel a lot. The price of falafel is highly volatile, and the best way to analyze the state of the economy is to go to the same falafel place every day and add up all the prices on their menu.
A falafel place has N different dishes on their menu. The ith dish has price p_i.
Every day, one of the following events happen:
INFLATION x: The integer x is added to all prices.SET x y: Every dish with price x gets its price set to y.Your task is to process Q days, and after each day print the sum of all prices p_i.
The first line contains one integer N, the number of dishes.
The second line contains N integers p_1,p_2,…,p_N.
The third line contains one integer Q, the number of days.
The following Q lines each contain a string s followed by either one or two integers.
If s is INFLATION, then one integer x follows. This means that x is added to all prices on this day.
If s is SET, then two integers x and y follow. This means that all dishes with price x get their price set to y on this day.
Print Q lines, the sum of all prices p_i after each day.
Note: The answer may not fit in a 32-bit integer, so be aware of overflows if you are using C++.
This figure corresponds to the first two days of sample 1. Note that the sum of prices after the first day is 16, so the first integer in the output is 16.
