Link to this code: https://cses.fi/paste/876360c03aaea114ad3ada/
#include "bits/stdc++.h"
using namespace std;
using LL = long long;

struct Segment {
	int n;
	vector<LL> t;
	Segment(int _n) : n(_n), t(2 * n) {}
	void update(int p, int x) {
		for (t[p += n] = x; p > 1; p >>= 1) {
			t[p >> 1] = t[p] + t[p ^ 1];
		}
	}
	LL query(int l, int r) {
		LL ans = 0;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) ans += t[l++];
			if (r & 1) ans += t[--r];
		}
		return ans;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;
	int q; cin >> q;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	Segment st(n);
	for (int i = 0; i < n; ++i) {
		st.update(i, a[i]);
	}

	for (int i = 0, t, a, b; i < q; ++i) {
		cin >> t >> a >> b;
		if (t == 1) {
			--a;
			st.update(a, b);
		} else {
			cout << st.query(a - 1, b) << "\n";
		}
	}
}