#include <iostream>
#include <cstdio>
using namespace std;
int n, m, a[15005], x, y, ai[60005], sumaInterval;
void citire()
{
scanf("%d %d", &n, &m);
for(int i=1; i<=n; ++i)
scanf("%d", &a[i]);
}
void build(int pai, int st, int dr)
{
if(st==dr)
{
ai[pai]=a[st];
return;
}
int mij=(st+dr)/2;
build(2*pai, st, mij);
build(2*pai+1, mij+1, dr);
ai[pai]=ai[pai*2]+ai[pai*2+1];
}
void achitare(int pai, int st, int dr)
{
if(st==dr)
{
ai[pai]-=y;
return;
}
int mij=(st+dr)/2;
if(x<=mij)
achitare(2*pai, st, mij);
else
achitare(2*pai+1, mij+1, dr);
ai[pai]=ai[pai*2]+ai[pai*2+1];
}
void interogare(int pai, int st, int dr)
{
if(st>=x && dr<=y)
{
sumaInterval+=ai[pai];
return;
}
int mij=(st+dr)/2;
if(mij>=x)
interogare(2*pai, st, mij);
if(mij<y)
interogare(2*pai+1, mij+1, dr);
}
int main()
{
freopen("datorii.in", "r", stdin);
freopen("datorii.out", "w", stdout);
citire();
build(1, 1, n);
for(int i=1; i<=m; ++i)
{
int u;
scanf("%d %d %d", &u, &x, &y);
if(u==1)
{
sumaInterval=0;
interogare(1, 1, n);
printf("%d ", sumaInterval);
}
else
{
achitare(1, 1, n);
}
}
return 0;
}