#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long LL; const int N = 50005; int n; int l,r; int t; int x; int a[N]; int tr[N<<2]; char s[10]; int lowbit(int x) { return x & -x; } void add(int x, int c) { for (int i = x; i <= n; i += lowbit(i)) tr[i] += c; } int sum(int x) { int res = 0; for (int i = x; i; i -= lowbit(i)) res += tr[i]; return res; } int main() { cin>>t; int kase=0; while(t--) { cin>>n; memset(tr,0,sizeof tr); for(int i=1;i<=n;i++) cin>>x,add(i,x); printf("Case %d: ", ++kase); while(cin>>s) { if(s[0]=='E') break; cin>>l>>r; if(s[0]=='A') add(l,r); else if(s[0]=='S') add(l,-r); else if(s[0]=='Q') cout<<sum(r)-sum(l-1)<<endl; } } }