# include <fstream>
# define NMAX 15001
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
int N, M;
long smax;
int A[4*NMAX];
void arb_update(int nod, int st, int dr, int poz, int val, int k) {
if(st == dr) {
if(!k) A[nod] = val;
else A[nod] -= val;
}
else {
int m = (st+dr)>>1;
if(poz <= m) arb_update(nod<<1, st, m, poz, val, k);
else arb_update((nod<<1)+1, m+1, dr, poz, val, k);
A[nod] = A[nod<<1] + A[(nod<<1)+1];
}
}
void arb_querry(int nod, int st, int dr, int a, int b) {
if(a <= st && dr <= b) {
smax += A[nod];
}
else {
int m = (st+dr)>>1;
if(a <= m) arb_querry(nod<<1, st, m, a, b);
if(b > m) arb_querry((nod<<1)+1, m+1, dr, a, b);
}
}
void citire() {
int i, val;
fin >> N >> M;
for(i = 1; i <= N; ++ i) {
fin >> val;
arb_update(1, 1, N, i, val, 0);
}
}
void more() {
int i, cod, a, b;
for(i = 1; i <= M; ++ i) {
fin >> cod >> a >> b;
if(!cod)
arb_update(1, 1, N, a, b, 1);
else {
smax = 0;
arb_querry(1, 1, N, a, b);
fout << smax << '\n';
}
}
}
int main() {
citire();
more();
return 0;
}