#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
int nums[15000], nrElem, nrQuery, i, tipOp, nr1, nr2;
vector <int> arbore(60000, -1), rez;
int constructie(int st, int dr, int poz)
{
if (st > dr) return 0;
if (st == dr) {arbore[poz] = nums[dr]; return arbore[poz];}
int stmax = constructie(st, st+(dr-st)/2, poz*2+1);
int drmax = constructie(st+(dr-st)/2+1, dr, poz*2+2);
arbore[poz] = stmax+drmax;
return arbore[poz];
}
int query(int poz, int stLocal, int drLocal, int stQuer, int drQuer)
{
if (drLocal < stQuer || stLocal > drQuer) return 0;
if (drLocal <= drQuer && stLocal >= stQuer) return arbore[poz];
return query(poz*2+1, stLocal, stLocal+(drLocal-stLocal)/2, stQuer, drQuer) + query(poz*2+2, stLocal+(drLocal-stLocal)/2+1, drLocal, stQuer, drQuer);
}
void modificare(int poz, int stLocal, int drLocal, int cineModif, int inCeModif)
{
if (stLocal > cineModif || drLocal < cineModif) return;
if (stLocal == drLocal) {arbore[poz] -= inCeModif; return;}
modificare(poz*2+1, stLocal, stLocal+(drLocal-stLocal)/2, cineModif, inCeModif);
modificare(poz*2+2, stLocal+(drLocal-stLocal)/2+1, drLocal, cineModif, inCeModif);
arbore[poz] = arbore[2*poz+1] + arbore[2*poz+2];
}
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(0);
fin >> nrElem >> nrQuery;
rez.reserve(nrQuery);
for (i = 0; i < nrElem; ++i)
fin >> nums[i];
constructie(0, nrElem-1, 0);
while (nrQuery--)
{
fin >> tipOp >> nr1 >> nr2;
if (tipOp == 0)
modificare(0, 0, nrElem-1, nr1-1, nr2);
else
rez.push_back(query(0, 0, nrElem-1, nr1-1, nr2-1));
}
for (auto i : rez)
fout << i << '\n';
return 0;
}