1 #include<cstdio>
2 #include<cstring>
3 #include<iostream>
4 #define sz 500050
5 using namespace std;
6 int t,n,m,c[sz];
7 string pd;
8 int lowbit(int x) {return x&(-x);}
9 void add(int x,int y) {for(int i = x; i <= n; i += lowbit(i)) c[i] += y;}
10 int ask(int x) {
11 int ans = 0;
12 for(int i = x; i > 0; i -= lowbit(i)) ans += c[i];
13 return ans;
14 }
15 int main() {
16 scanf("%d",&t);
17 for(int i = 1; i <= t; i++) {
18 memset(c,0,sizeof(c));//!!!!!!
19 scanf("%d",&n);
20 printf("Case %d:
",i);
21 int a,x,y;
22 for(int i = 1; i <= n; i++) {
23 scanf("%d",&a);
24 add(i,a);
25 }
26 while(1) {
27 cin>>pd;
28 if(pd == "End") break;
29 scanf("%d%d",&x,&y);
30 if(pd == "Add") add(x,y);
31 else if(pd == "Query") printf("%d
",ask(y) - ask(x-1));
32 else if(pd == "Sub") add(x,-y);
33
34 }
35 }
36 return 0;
37 }