River Gauges
The flood office keeps n rain gauges along a river, numbered 1 to n from the source to the
mouth. Gauge i currently shows a reading of a_i millimetres.
During the storm season the office receives q messages, which must be handled in the order they
arrive. Each message is one of two kinds:
reading i x: the warden at gaugeireports that the gauge now showsx. This replaces the gauge's previous reading; it is not added to it. Every later message sees the new value.total l r: a dispatcher asks for the total rainfall shown right now by all gauges on the stretch of river between gaugeland gauger, both included. The two ends may be given in either order (the stretch between gauges5and2consists of gauges2, 3, 4, 5), and they may be the same gauge.
Answer every total message.
Input
The first line contains two integers n and q (1 ≤ n ≤ 2·10^5, 1 ≤ q ≤ 2·10^5): the number of
gauges and the number of messages.
The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9): the initial readings.
Each of the next q lines contains one message, either reading i x (1 ≤ i ≤ n, 0 ≤ x ≤ 10^9) or
total l r (1 ≤ l, r ≤ n). The kind is written exactly as shown, in lowercase.
Output
For each total message, in the order they arrive, print one line with the requested total. If
there are no total messages, print nothing.
Notes
In the first example the stretch between gauges 2 and 4 initially shows 1 + 4 + 1 = 6. Then
gauge 3 is reset from 4 to 0, so the same stretch now shows 2, and the whole river shows
3 + 1 + 0 + 1 + 5 = 10. The last message asks about gauge 5 alone.
In the second example the ends of the stretch are given in reverse order, and readings can be large enough that totals do not fit in a 32-bit integer.