#include using namespace std; #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; ll dat[MAX_N]; ll maxi[sqrtN]; ll 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;} inline int get_j2(int x) { int ret = x % sqrtN; if(ret == 0) return sqrtN; return ret; } void add(int l, int r, ll 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) { maxi[i] += s; lazy[i] += s; } else { REP(j, 0, sqrtN) { dat[get_idx(i, j)] += lazy[i]; } lazy[i] = 0; REP(j, get_j(max(x, l)), get_j2(min(y, r))) { dat[get_idx(i, j)] += s; } maxi[i] = -1e18; REP(j, 0, sqrtN) { maxi[i] = max(maxi[i], dat[get_idx(i, j)]); } } } } ll query(int l, int r) { ll ret = -1e18; REP(i, get_i(l), sqrtN) { int x = get_idx(i, 0), y = x + sqrtN; if(r <= x) break; if(l <= x && y <= r) { ret = max(ret, maxi[i]); } else { REP(j, 0, sqrtN) { dat[get_idx(i, j)] += lazy[i]; } lazy[i] = 0; REP(j, get_j(max(x, l)), get_j2(min(y, r))) { ret = max(ret, dat[get_idx(i, j)]); } } } return ret; } int main(){ int n; cin >> n; rep(i, n-1) { ll a; cin >> a; dat[i] = a + 3 * (n - i - 1); } rep(i, n) maxi[get_i(i)] = max(maxi[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; }