include<bits/stdc++.h>

const int MAXN=200015;

using namespace std;
int mark[MAXN],a[MAXN],b[MAXN];

int _find(int x){
if(x==0)return x;
if(a[x]!=b[x])return x;
return mark[x]=mark[x+1]=_find(mark[x+1]);
}

int main(){
int n,m,x,y,d;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
b[i]=0;
mark[i]=i;
}
int op;
while(m--){
scanf("%d",&op);
if(op==2){
scanf("%d%d",&x,&y);
while(y){
x=_find(x);
if(x==0)break;
d=min(a[x]-b[x],y);
b[x]+=d;
y-=d;
}
}else{
scanf("%d",&x);
printf("%d\n",b[x]);
}
}
return 0;
}