#include <iostream>
#include <fstream>
using namespace std;
ifstream f("datorii.in");
ofstream g("datorii.out");
int v[400005], s_rest;
void update(int nod, int st, int dr, int poz, int val, bool plati = false)
{
if (st==dr)
{
if (plati)
v[nod] -= val;
else
v[nod] = val;
}
else
{
int mid = (st+dr)/2;
if (mid >= poz)
update(nod*2, st, mid, poz, val, plati);
else
update(nod*2 +1,mid+1, dr, poz, val, plati);
v[nod] = v[nod*2] + v[nod*2 +1];
}
}
void achitare(int nod, int st, int dr, int a, int b)
{
if (a<=st && dr<=b)
{
s_rest += v[nod];
return;
}
int mid = (st+dr)/2;
if (mid >= a)
achitare(nod*2, st, mid, a, b);
if (mid+1 <= b)
achitare(nod*2+1, mid+1, dr, a, b);
}
int main(void)
{
int n, m, x, op, a, b, i;
f>>n>>m;
for (i=1; i<=n; i++)
{
f >> x;
update(1, 1, n, i, x);
}
for (i=1;i<=m; i++)
{
f>>op>>a>> b;
if (op == 1)
{
s_rest=0;
achitare(1, 1, n, a, b);
g<<s_rest<<'\n';
}
else
update(1, 1, n, a, b, 1);
}
return 0;
}