#include #include using namespace std; struct AddTree { vector t; int half; AddTree (vector & a, int n) { half = 1; while (half < n) half *= 2; t = vector (half * 2); for (int i = 0; i < n; i++) t[i + half] = a[i]; } int ask (int pos) { int res = 0; for (pos += half; pos > 0; pos /= 2) res += t[pos]; return res; } void add (int lo, int hi, int x) { for (lo += half, hi += half; lo < hi; lo /= 2, hi /= 2) { if (lo & 1) t[lo++] += x; if (hi & 1) t[--hi] += x; } } }; int main () { int n, m; cin >> n >> m; vector a (n); for (int i = 0; i < n; i++) cin >> a[i]; AddTree z (a, n); for (int j = 0; j < m; j++) { string type; cin >> type; if (type == "add") { int lo, hi, x; cin >> lo >> hi >> x; z.add (lo - 1, hi, x); } if (type == "ask") { int i; cin >> i; cout << z.ask (i - 1) << endl; } } return 0; }