import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Map.Entry; import java.util.PriorityQueue; import java.util.Scanner; import java.util.TreeSet; public class Main { public static class LazyAddSumSegmentTree{ int n; long[] dat, lazy; public LazyAddSumSegmentTree(int n_) { int n = 1; while(n < n_){ n *= 2;} this.n = n; dat = new long[this.n * 2 - 1]; lazy = new long[this.n * 2 - 1]; } private void evaluate_lazy(int k, int l, int r){ dat[k] += lazy[k]; if(k < n - 1){ lazy[2 * k + 1] += lazy[k]; lazy[2 * k + 2] += lazy[k]; } lazy[k] = 0; } public void update_node(int k, int l, int r){ final int mid = (l + r) / 2; final int size = r - mid; dat[k] = Math.max(dat[2*k+1] + 3 * size, dat[2*k+2]); } public void add(long v, int a, int b){ add(v, a, b, 0, 0, this.n); } public void add(long v, int a, int b, int k, int l, int r){ evaluate_lazy(k, l, r); if(r <= a || b <= l){ return; }else if(a <= l && r <= b){ lazy[k] += v; evaluate_lazy(k, l, r); }else { add(v, a, b, k * 2 + 1, l , (l + r) / 2); add(v, a, b, k * 2 + 2, (l + r) / 2, r); update_node(k, l, r); } } public long max(int a, int b){ return max(a, b, 0, 0, this.n); } public long max(int a, int b, int k, int l, int r){ evaluate_lazy(k, l, r); if(r <= a || b <= l){ return -1; }else if(a <= l && r <= b){ return dat[k]; }else { long v1 = max(a, b, k * 2 + 1, l , (l + r) / 2); long v2 = max(a, b, k * 2 + 2, (l + r) / 2, r); update_node(k, l, r); if(v1 < 0){ return v2; } if(v2 < 0){ return v1; } final int mid_size = b - (l + r) / 2; return Math.max(v1 + 3 * mid_size, v2); } } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); long[] ts = new long[N - 1]; for(int i = 0; i < N - 1; i++){ ts[i] = sc.nextLong(); } LazyAddSumSegmentTree seg = new LazyAddSumSegmentTree(N); for(int i = 0; i < N - 1; i++){ seg.add(ts[i], i, i + 1); } //System.out.println(Arrays.toString(seg.dat)); final int M = sc.nextInt(); for(int q = 0; q < M; q++){ final int L = sc.nextInt() - 1; final int R = sc.nextInt(); final long D = sc.nextLong(); seg.add(D, L, R); System.out.println(seg.max(0, N)); //System.out.print(q + " :"); //for(int i = 0; i < N; i++){ System.out.print(" " + seg.max(i, i + 1)); } //System.out.println(); } } }