#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN=2e5+5;
int n,m,a[MAXN];
struct node{
int l,r,len,val,cnt;
}t[MAXN<<2];
void push_up(int rt){
t[rt].val=t[rt<<1].val+t[rt<<1|1].val;
t[rt].cnt=t[rt<<1].cnt+t[rt<<1|1].cnt;
}
void build(int rt,int l,int r){
t[rt].l=l;
t[rt].r=r;
t[rt].len=r-l+1;
if(l==r){
if(a[l]>-1e18){
t[rt].val=a[l];
t[rt].cnt=1;
}
return;
}
int mid=(l+r)>>1;
build(rt<<1,l,mid);
build(rt<<1|1,mid+1,r);
push_up(rt);
}
void update(int rt,int x,int addval){
if(t[rt].l==t[rt].r){
t[rt].val-=addval;
return;
}
if(x<=t[rt<<1].r){
update(rt<<1,x,addval);
}else{
update(rt<<1|1,x,addval);
}
push_up(rt);
}
void Ins(int rt,int x,int addval){
if(t[rt].l==t[rt].r){
t[rt].cnt=1;
t[rt].val=addval;
return;
}
if(x<=t[rt<<1].r){
Ins(rt<<1,x,addval);
}else{
Ins(rt<<1|1,x,addval);
}
push_up(rt);
}
void del(int rt,int x){
if(t[rt].l==t[rt].r){
t[rt].val=0;
t[rt].cnt=0;
return;
}
if(x<=t[rt<<1].cnt){
del(rt<<1,x);
}else{
del(rt<<1|1,x-t[rt<<1].cnt);
}
push_up(rt);
}
signed main(){
cin>>n>>m;
memset(a,0xc0,sizeof(a));
for(int i=1;i<=n;i++){
cin>>a[i];
}
build(1,1,MAXN);
for(int i=1;i<=m;i++){
char op;
cin>>op;
if(op=='C'){
int x,y;
cin>>x>>y;
update(1,x,y);
}else if(op=='I'){
int x,y;
cin>>x>>y;
Ins(1,x,y);
}else if(op=='D'){
int x;
cin>>x;
del(1,x);
}else{
cout<<t[1].val<<endl;
}
}
return 0;
}