#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream cin("rsq.in");
ofstream cout("rsq.out");
ios::sync_with_stdio(false);
unsigned int n, m, i;
long long sum = 0, sum_k;
int *a, x, y;
bool t;
cin >> n >> m; n++;
a = new int[n];
for (i = 1; i < n; i++)
{
cin >> a[i];
sum += a[i];
}
const unsigned int ndiv2 = n/2;
while (m--)
{
cin >> t >> x;
if (t)
{
sum -= a[x];
cin >> a[x];
sum += a[x];
}
else
{
cin >> y;
y++;
if (y - x > ndiv2)
{
sum_k = sum;
for (i = 1; i < x; i++)
{
sum_k -= a[i];
}
for (i = y; i < n; i++)
{
sum_k -= a[i];
}
}
else
{
sum_k = 0;
for (; x < y; x++)
{
sum_k += a[x];
}
}
cout << sum_k << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewoJaWZzdHJlYW0gY2luKCJyc3EuaW4iKTsKCW9mc3RyZWFtIGNvdXQoInJzcS5vdXQiKTsKCWlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKCXVuc2lnbmVkIGludCBuLCBtLCBpOwoJbG9uZyBsb25nIHN1bSA9IDAsIHN1bV9rOwoJaW50ICphLCB4LCB5OwoJYm9vbCB0OwoJY2luID4+IG4gPj4gbTsgbisrOwoJYSA9IG5ldyBpbnRbbl07Cglmb3IgKGkgPSAxOyBpIDwgbjsgaSsrKQoJewoJCWNpbiA+PiBhW2ldOwoJCXN1bSArPSBhW2ldOwoJfQoJY29uc3QgdW5zaWduZWQgaW50IG5kaXYyID0gbi8yOwoJd2hpbGUgKG0tLSkKCXsKCQljaW4gPj4gdCA+PiB4OwoJCWlmICh0KQoJCXsKCQkJc3VtIC09IGFbeF07CgkJCWNpbiA+PiBhW3hdOwoJCQlzdW0gKz0gYVt4XTsKCQl9CgkJZWxzZQoJCXsKCQkJY2luID4+IHk7CgkJCX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