#include using namespace std; #define int long long #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #define fi first #define se second typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; const int INF = 1e9; const ll MOD = 1e9 + 7; double EPS = 1e-8; const int sqrtN = 350; const int MAX_N = sqrtN * sqrtN + 1; using TYPE = ll; const TYPE DFLT = -1e18; // max => -INF, min => INF, sum => 0 // change f1, f2 inline void f1(TYPE& a, const TYPE& b) { a+=b; } inline void f2(TYPE& a, const TYPE& b) { a = max(a, b); } TYPE dat[MAX_N]; TYPE ans[sqrtN]; TYPE lazy[sqrtN]; inline int get_i(int x) {return x / sqrtN;} inline int get_j(int x) {return x % sqrtN;} inline int get_idx(int i, int j) {return i * sqrtN + j;} void calcLazy(int i) { REP(j, 0, sqrtN) { f1(dat[get_idx(i, j)], lazy[i]); } lazy[i] = 0; } void add(int l, int r, TYPE s) { REP(i, get_i(l), sqrtN) { int x = get_idx(i, 0), y = x + sqrtN; if (r <= x) break; if (l <= x && y <= r) { f1(ans[i], s); f1(lazy[i], s); } else { calcLazy(i); REP(idx, max(x, l), min(y, r)) { f1(dat[idx], s); } } } } TYPE query(int l, int r) { TYPE ret = DFLT; REP(i, get_i(l), sqrtN) { int x = get_idx(i, 0), y = x + sqrtN; if (r <= x) break; if (l <= x && y <= r) { f2(ret, ans[i]); } else { calcLazy(i); REP(idx, max(x, l), min(y, r)) { f2(ret, dat[idx]); } } } return ret; } signed main() { int n; cin >> n; rep(i, n - 1) { ll a; cin >> a; dat[i] = a + 3 * (n - i - 1); } rep(i, n) ans[get_i(i)] = max(ans[get_i(i)], dat[i]); int m; cin >> m; rep(i, m) { int l, r, d; cin >> l >> r >> d; --l; add(l, r, (ll)d); cout << query(0, n) << endl; } return 0; }