#include <iostream>
#include <cstdio>
using namespace std;
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()
{
freopen("datorii.in", "r", stdin);
freopen("datorii.out", "w", stdout);
scanf("%d%d", &N, &M);
for(i=1; i<=N; ++i) {
int x;
scanf("%d", &x);
T.Reduce(x, i, false);
}
for(i=1; i<=M; ++i){
int a, b, c;
scanf("%d%d%d", &c, &a, &b);
if(c==1) printf("%d\n", T.Sum(a, b));
else T.Reduce(b, a, true);
}
return 0;
}