#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e+5,mod=10000;
int n;
ll a[maxn+5],c[maxn+5],c2[maxn+5];
int lowbit(int x)
{
return x&(-x);
};
void add(int x,ll y)
{
for(;x<=n;x+=lowbit(x))
{
c[x]+=y;
}
}
void add2(int x, ll y)
{
for(;x<=n;x+=lowbit(x)) c2[x]+=y;
}
ll sum(int x){
ll tmp=0;
for(;x;x-=lowbit(x)) tmp+=c[x];
return tmp;
}
ll sum2(int x){
ll tmp=0;
for(;x;x-=lowbit(x)) tmp+=c2[x];
return tmp;
}
int main()
{
int m;
cin>>n>>m;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
add(i,a[i]);add2(i,i*a[i]);
}
string st;int id;ll x;
for(int i=1;i<=m;i++)
{
cin>>st;
if(st[0]=='Q')
{
cin>>id;
cout<<(id+1)*sum(id)-sum2(id)<<endl;
}
else {
cin>>id>>x;
add(id,x-a[id]);
add2(id,(x-a[id])*id);
}
}
/*for(int i=1;i<=n;i++)
cout<<sum(i)<<" ";*/
return 0;
}
```cpp