#include<iostream>
using namespace std;
const int maxn=10005;
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
int tree_sum[maxn<<2];
void build(int root,int l,int r)
{
if(l==r)
{
cin>>tree_sum[root];
return ;
}
int mid=(l+r)>>1;
build(root<<1,l,mid);
build(root<<1|1,mid+1,r);
tree_sum[root]=tree_sum[root<<1]+tree_sum[root<<1|1];
}
void update(int root,int l,int r,int pos,int val)
{
if(l==r&&l==pos)
{
tree_sum[root]=val;
return ;
}
int mid=(l+r)>>1;
if(pos<=mid)
update(root<<1,l,mid,pos,val);
else
update(root<<1|1,mid+1,r,pos,val);
tree_sum[root]=tree_sum[root<<1]+tree_sum[root<<1|1];
}
int query(int root,int l,int r,int L,int R)
{
if(L<=l&&r<=R)
{
return tree_sum[root];
}
int mid=(r+l)>>1,sum=0;
if(L<=mid)
sum+=query(root<<1,l,mid,L,R);
if(mid<R)
sum+=query(root<<1|1,mid+1,r,L,R);
return sum;
}
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
build(l,n,l);
while(m--)
{
char op[2];
int a,b;
cin>>op>>a>>b;
if(op[0]=='Q')
printf("%d\n",query(a,b,l,n,l));
else update(a,b,l,n,l);
}
}
return 0;
}