Link to this code: https://cses.fi/paste/ef5637a93e7757c3ad3b0a/
#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) {}
	LL query(int p) {
		LL ans = 0;
		for (p += n; p > 0; p >>= 1) {
			ans += t[p];
		}
		return ans;
	}
	void update(int l, int r, int x) {
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) t[l++] += x;
			if (r & 1) t[--r] += x;
		}
	}
};

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, i+1, a[i]);
	}

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