#include <iostream>
using namespace std;
#define int long long int
const int N = 2e5+10;
int arr[N];
int segTree[4*N+1];
void buildSegTree(int idx, int low, int high){
if(low == high){
segTree[idx] = arr[low];
return;
}
int mid = (low + high) >> 1;
buildSegTree(2*idx, low, mid);
buildSegTree(2*idx+1, mid+1, high);
segTree[idx] = segTree[2*idx]+segTree[2*idx+1];
}
void updateSegTreePoint(int idx, int low, int high, int index, int val){
if(index<low or index>high){
return;
}
if(low == high){
segTree[idx] = val;
return;
}
int mid = (low+high)>>1;
if(index <= mid){
updateSegTreePoint(2*idx, low, mid, index, val);
} else {
updateSegTreePoint(2*idx+1, mid+1, high, index, val);
}
segTree[idx] = segTree[2*idx]+segTree[2*idx+1];
}
int querySegTree(int idx, int low, int high, int qs, int qe){
if(qs <= low and high <= qe){
return segTree[idx];
}
if(qe<low or qs>high or low>high){
return 0;
}
int mid = (low+high)>>1;
int left = querySegTree(2*idx, low, mid, qs, qe);
int right = querySegTree(2*idx+1, mid+1, high, qs, qe);
return left+right;
}
int32_t main() {
int n, q;
cin >> n >> q;
for(int i=0; i<n; i++){
cin>>arr[i];
}
buildSegTree(1, 0, n-1);
while(q--){
int t, a, b;
cin >> t >> a >> b;
if(t==1){
updateSegTreePoint(1, 0, n-1, a-1, b);
} else {
cout << querySegTree(1, 0, n-1, a-1, b-1) << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGludCBsb25nIGxvbmcgaW50CmNvbnN0IGludCBOID0gMmU1KzEwOwoKaW50IGFycltOXTsKaW50IHNlZ1RyZWVbNCpOKzFdOwoKdm9pZCBidWlsZFNlZ1RyZWUoaW50IGlkeCwgaW50IGxvdywgaW50IGhpZ2gpewoJaWYobG93ID09IGhpZ2gpewoJCXNlZ1RyZWVbaWR4XSA9IGFycltsb3ddOwoJCXJldHVybjsKCX0KCWludCBtaWQgPSAobG93ICsgaGlnaCkgPj4gMTsKCWJ1aWxkU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