/*Folosim Arbori de intervale
*/
#include<fstream>
#include<vector>
#include<string>
const int NMAX = 100000;
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
string sir;
int i, n, k, j, m, nr, sol, x , y;
int MaxArb[4 * NMAX + 5];
void query(int nod, int stanga, int dreapta, int start, int finish)
{
if(start <= stanga && dreapta <= finish)
{
sol = sol + MaxArb[nod];
return;
}
int mij = (stanga + dreapta) / 2;
if(start <= mij)
{
query(2 * nod, stanga, mij, start, finish);
}
if(mij < finish)
{
query(2 * nod + 1, mij + 1, dreapta, start, finish);
}
}
void update(int nod, int stanga, int dreapta, int position, int value, bool construieste)
{
if(stanga == dreapta)
{
if(construieste == true)
{
MaxArb[nod] = value;
}
else
{
MaxArb[nod] -= value;
}
return;
}
int mij = (stanga + dreapta) / 2;
if(position <= mij)
{
update(2 * nod, stanga, mij, position, value, construieste);
}
else
{
update(2 * nod + 1, mij + 1, dreapta, position, value, construieste);
}
MaxArb[nod] = MaxArb[2 * nod] + MaxArb[2 * nod + 1];
}
int main()
{
fin >> n >> m;
for(i = 1; i <= n; i++)
{
fin >> nr;
update(1, 1, n, i, nr, true);
}
for(i = 1; i <= m; i++)
{
fin >> nr >> x >> y;
if(nr == 0)
{
update(1, 1, n, x, y, false);
}
else
{
sol = 0;
query(1, 1, n, x, y);
fout << sol << "\n";
}
}
for(i = 1; i <= 2*n; i++)
{
//fout << MaxArb[i] << " ";
}
}