#include #include #include #include #include #include #include using namespace std; struct SegmentTree { struct Node { Node operator*(const Node& o) const { return { max(m, o.m) }; } int64_t m; }; using Lazy = int64_t; SegmentTree(int n) : e({ -((int64_t)1 << 60) }), n(n) { for (m = 2; m < n; m *= 2); t = vector(m + n + n % 2, e); z = vector(m, 0); } Node& operator[](int i) { return t[m + i]; } const Node& root() const { return t[1]; } void build() { for (int i = (n - 1 + m) / 2; i > 0; i--) { t[i] = t[i * 2] * t[i * 2 + 1]; } } void range_act(int l, int r, Lazy x, int i = 1, int il = 0, int ir = -1) { if (ir < 0) ir = m; if (l <= il && ir <= r) { act(i, x); return; } propagate(i); int ic = (il + ir) / 2; if (l < ic) range_act(l, r, x, i * 2 + 0, il, ic); if (ic < r) range_act(l, r, x, i * 2 + 1, ic, ir); t[i] = t[i * 2] * t[i * 2 + 1]; } void propagate(int i) { if (z[i] == 0) return; act(i * 2 + 0, z[i]); act(i * 2 + 1, z[i]); z[i] = 0; } void act(int i, Lazy x) { t[i].m += x; if (i < m) z[i] += x; } vector t; vector z; const Node e; int n, m; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; n--; SegmentTree st(n); for (int i = 0; i < n; i++) { cin >> st[i].m; st[i].m += 3 * (n - i); } st.build(); int m; cin >> m; for (int i = 0; i < m; i++) { int l, r, d; cin >> l >> r >> d; l--; st.range_act(l, r, d); cout << st.root().m << '\n'; } return 0; }