#SGM0000003. Biến trở (Potentiometers)

Biến trở (Potentiometers)

Potentiometers

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

There are NN potentiometers arranged from 11 to NN. Each value is a resistance in Ohms, and the resistance of a contiguous series is the sum of its values. Process point assignments and range measurements.

Input

  • The first line contains NN and QQ: the number of potentiometers and operations.
  • The second line contains NN initial resistances, each from 00 to 10001000.
  • Each of the next QQ lines is S x r, which sets position xx to rr, or M x y, which asks for the sum from xx through yy, where 1≤x≤y≤N1 \le x \le y \le N.

Output

For every M operation, print the measured range sum.

Subtasks

  • Subtask 1 — 20%: 1≤N,Q≤10001 \le N,Q \le 1000.
  • Subtask 2 — 30%: 1≤N,Q≤500001 \le N,Q \le 50000.
  • Subtask 3 — 50%: 1≤N,Q≤2000001 \le N,Q \le 200000.

Examples

Input

3 6
100 100 100
M 1 1
M 1 3
S 2 200
M 1 2
S 3 0
M 2 3

Output

100
300
300
200

Explanation

The three initial values are all 100100. The first two measurements are 100100 and 300300. After setting position 22 to 200200, the sum on [1,2][1,2] is 100+200=300100+200=300. After setting position 33 to 00, the sum on [2,3][2,3] is 200+0=200200+0=200.