#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
#include <cstring>
#include <map>
#include <iomanip>
#include <time.h>
//#include <iostream>
using namespace std;
ifstream cin("datorii.in");
ofstream cout("datorii.out");
int x[500007], n, a, b, v, bit, m, mi = 0, y[15004];
void querry(int nod, int st, int dr, int val, int poz)
{
if(st == dr)
{
x[nod] = val;
return ;
}
int m = (st + dr) / 2;
if(poz <= m)
querry(nod * 2, st, m, val, poz);
else
querry(nod * 2 + 1, m + 1, dr, val, poz);
x[nod] = x[nod * 2] + x[nod * 2 + 1];
}
void interog(int a, int b, int nod, int st, int dr)
{
if(a <= st && b >= dr)
{
mi += x[nod];
return ;
}
int m = (st + dr) / 2;
if(a <= m)
interog(a, b, nod * 2, st, m);
if(b > m)
interog(a, b, nod * 2 + 1, m + 1, dr);
}
int main(){
cin >> n >> m;
for(int i = 0; i < n; i++)
{
cin >> v;
y[i] = v;
querry(1, 0, n - 1, v, i);
}
for(int i = 0; i < m; i++)
{
cin >> bit;
if(bit == 1)
{
cin >> a >> b;
mi = 0;
interog(a - 1, b - 1, 1, 0, n - 1);
cout << mi << "\n";
}
else
{
cin >> a >> b;
y[a - 1] -= b;
querry(1, 0, n - 1, y[a - 1], a - 1);
}
}
return 0;
}