#include <fstream>
using namespace std;
ifstream in ("arbint.in");
ofstream out ("arbint.out");
int n, m, v[15001], a[100001];
void build (int nod, int s, int d)
{
if (s == d)
{
a[nod] = v[s];
return;
}
int m = (s + d) / 2;
build(nod * 2, s, m);
build(nod * 2 + 1, m + 1, d);
a[nod] = a[nod * 2] + a[nod * 2 + 1];
}
void update (int nod, int s, int d, int poz, int val)
{
if (s == d)
{
a[nod] = max(a[nod] - val, 0);
return;
}
int m = (s + d) / 2;
if (poz <= m)
update (nod * 2, s, m, poz, val);
else
update (nod * 2 + 1, m + 1, d, poz, val);
a[nod] = a[nod * 2] + a[nod * 2 + 1];
}
int query (int nod, int s, int d, int l, int r)
{
if (d < l || s > r)
return 0;
if (l <= s && d <= r)
return a[nod];
int m = (s + d) / 2;
return query(nod * 2, s, m, l, r) + query(nod * 2 + 1, m + 1, d, l, r);
}
int main()
{
in >> n >> m;
for (int i = 1; i <= n; i++)
in >> v[i];
build (1, 1, n);
int tip, x, y;
for (int i = 1; i <= m; i++)
{
in >> tip >> x >> y;
if (tip == 0)
{
update (1, 1, n, x, y);
}
else
{
out << query(1, 1, n, x, y) << '\n';
}
}
in.close();
out.close();
return 0;
}