#include<iostream>
#include<fstream>
using namespace std;
ifstream cit("datorii.in");
ofstream afis("datorii.out");
int N, M, arbore[100001], vec[15001], op, x, y, num;
void constrArbore(int st, int dr, int index){
int mij;
if(st == dr){
arbore[index] = vec[st];
}
else{
mij = (st + dr)/2;
constrArbore(st, mij, 2 * index);
constrArbore(mij + 1, dr, 2 * index + 1);
arbore[index] = arbore[2 * index] + arbore[2 * index + 1];
}
}
int interogare(int st, int dr, int index, int x, int y){
int suma1, suma2, mij;
if((x <= st) && (y >= dr)){
return arbore[index];
}
else{
suma1 = 0;
suma2 = 0;
mij = (st + dr)/2;
if(x <= mij){
suma1 = interogare(st, mij, 2 * index, x, y);
}
if(y > mij){
suma2 = interogare(mij + 1, dr, 2 * index + 1, x, y);
}
suma1 += suma2;
return suma1;
}
}
void plateste(int st, int dr, int index, int x, int y){
int mij;
if(st == dr){
arbore[index] -= y;
}
else{
mij = (st + dr)/2;
if(x <= mij){
plateste(st, mij, 2 * index, x, y);
}
else{
plateste(mij + 1, dr, 2 * index + 1, x, y);
}
arbore[index] = arbore[2 * index] + arbore[2 * index + 1];
}
}
int main()
{
cit>>N>>M;
for(int i = 1; i <= N; i++){
cit>>vec[i];
}
constrArbore(1, N, 1);
for(int i = 1; i <= M; i++){
cit>>op>>x>>y;
if(op == 0){
plateste(1, N, 1, x, y);
}
else{
num = interogare(1, N, 1, x, y);
afis<<num<<"\n";
}
}
return 0;
}