#include <iostream> #include <algorithm> #include <cstdio> #include <cstring>using namespace STD; #define MAXN 1000001#define inf 0x3f3f3f3fint ll[maxn<<2],rr[maxn<<2],sum[maxn<<2];int A[MAXN] ; void build (int l,int r,int i) {ll[i]=l; Rr[i]=r; if (Ll[i]==rr[i]) {sum[i]=a[l]; return; } int m= (L+R) >>1,ls=i<<1,rs=ls|1; Build (L,m,ls); Build (M+1,R,RS); SUM[I]=SUM[LS]+SUM[RS];} void update (int k,int V,int i) {if (Ll[i]==rr[i]) {sum[i]+=v; Return } int m= (Ll[i]+rr[i]) >>1,ls=i<<1,rs=ls|1; if (k<=m) {update (K,V,LS); } else{Update (K,V,RS); } Sum[i]=sum[ls]+sum[rs];} int finds (int l,int r,int i) {if (ll[i]==l&&rr[i]==r) {return sum[i]; } int m= (Ll[i]+rr[i]) >>1,ls=i<<1,rs=ls|1; if (r<=m) {return finds (L,R,LS); } else if (l>m) {return finds (L,R,RS); } else{return finds (L,m,ls) +fiNDS (M+1,R,RS); }}int Main () {int n,m; int x, y; int a,i; Char q[10]; Freopen ("In.txt", "R", stdin); while (~SCANF ("%d%d", &n,&m)) {for (int i=1;i<=n;i++) {scanf ("%d", &a[i]); } build (1,n,1); for (int i=1;i<=m;i++) {scanf ("%s", q); if (!strcmp (q, "QUERY")) {scanf ("%d%d", &x,&y); printf ("%d\n", Finds (x,y,1)); } else {scanf ("%d%d", &a,&i); Update (a,i,1); } } }}