#include<bits/stdc++.h>
using namespace std;
const int MAX=500020;
int tree[MAX];
int A[100005];
void Build_Tree(int node, int st, int end)
{
if(st == end)
{
tree[node] = A[st];
return ;
}
int mid = (st+end)/2;
Build_Tree(node*2, st, mid);
Build_Tree(node*2+1, mid+1, end);
tree[node] = tree[2*node] + tree[2*node+1];
return;
}
void update(int node, int st, int end, int idx, int value)
{
if(st == end)
{
tree[node] = value;
tree[node] = value;
A[idx] = value;
return ;
}
int mid = (st+end)/2;
if(idx<=mid)
{
update(2*node, st, mid, idx, value);
}
else
{
update(2*node+1, mid+1, end, idx, value);
}
tree[node] = tree[2*node] + tree[2*node+1];
return ;
}
int RangeSum(int node, int st, int end, int l, int r)
{
if(l <= st && end <= r )
{
return tree[node];
}
if(st>r || end<l)
return 0;
int mid = (st+end)/2;
int ans1 = RangeSum(2*node, st, mid, l, r);
int ans2 = RangeSum(2*node+1, mid+1, end, l, r);
return ans1 + ans2;
}
int main()
{
int n,q,l,r,a;
cin>>n>>q;
for(int i=0;i<MAX;i++)
tree[i]=0;
for(int i=1;i<=n;i++) {
cin>>A[i];
}
Build_Tree(1,1,n);
while(q--)
{
cin>>a>>l>>r;
if(a==0)
{
cout<<RangeSum(1,1,n,l,r)<<endl;
}
else
{
update(1,1,n,l,r);
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBNQVg9NTAwMDIwOwoKaW50IHRyZWVbTUFYXTsKaW50IEFbMTAwMDA1XTsKCnZvaWQgQnVpbGRfVHJlZShpbnQgbm9kZSwgaW50IHN0LCBpbnQgZW5kKQp7CglpZihzdCA9PSBlbmQpCgl7CgkJdHJlZVtub2RlXSA9IEFbc3RdOwoJCXJldHVybiA7Cgl9CglpbnQgbWlkID0gKHN0K2VuZCkvMjsKCUJ1aWxkX1RyZWUobm9kZSoyLCBzdCwgbWlkKTsKCQoJQnVpbGRfVHJlZShub2RlKjIrMSwgbWl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