#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
int N, M, i;
class BTree{
int V[60001];
int Get(int left, int right, int a, int b, int position){
int mid=(a+b)/2;
if(left==a && right==b) return V[position];
if(right<=mid) return Get(left, right, a, mid, 2*position);
else if(left>mid) return Get(left, right, mid+1, b, 2*position+1);
else return Get(left, mid, a, mid, 2*position)+Get(mid+1, right, mid+1, b, 2*position+1);
}
void Set(int val, int target, int a, int b, int position, bool c){
int mid=(a+b)/2;
if(a==target && b==target){
if(c==true) V[position]-=val;
else V[position]=val;
return;
}
if(target<a || target>b) return;
Set(val, target, a, mid, 2*position, c);
Set(val, target, mid+1, b, 2*position+1, c);
V[position]=V[2*position]+V[2*position+1];
return;
}
public:
int Sum(int left, int right){
return Get(left, right, 1, N, 1);
}
void Reduce(int val, int target, bool c){
Set(val, target, 1, N, 1, c);
}
};
BTree T;
int main()
{
fin>>N>>M;
for(i=1; i<=N; ++i) {
int x;
fin>>x;
T.Reduce(x, i, false);
}
for(i=1; i<=M; ++i){
int a, b, c;
fin>>c>>a>>b;
if(c==1) fout<<T.Sum(a, b)<<"\n";
else T.Reduce(b, a, true);
}
return 0;
}