import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return sys.stdin.readline()[:-1] class LazySeg: def __init__(self, aa): inf = 10 ** 16 n = 1 << (len(aa) - 1).bit_length() tree = [-inf] * (2 * n) lazy = [0] * (2 * n) tree[n:n + len(aa)] = aa for u in range(n - 1, 0, -1): tree[u] = max(tree[u * 2], tree[u * 2 + 1]) self.tree = tree self.lazy = lazy self.n = n self.inf = inf def add(self, l, r, a, u=1, tl=0, tr=-1): if tr == -1: tr = self.n if r <= tl or tr <= l: return if l <= tl and tr <= r: self.lazy[u] += a return tm = (tl + tr) // 2 self.add(l, r, a, u * 2, tl, tm) self.add(l, r, a, u * 2 + 1, tm, tr) def max(self, l, r, u=1, tl=0, tr=-1): if tr == -1: tr = self.n if r <= tl or tr <= l: return -self.inf if l <= tl and tr <= r: self._eval(u) return self.tree[u] self.lazy[u*2]+=self.lazy[u] self.lazy[u*2+1]+=self.lazy[u] self.lazy[u]=0 tm = (tl + tr) // 2 return max(self.max(l, r, u * 2, tl, tm),self.max(l, r, u * 2 + 1, tm, tr)) def _eval(self, u): if u>=self.n: self.tree[u]+=self.lazy[u] self.lazy[u]=0 return self.lazy[u*2]+=self.lazy[u] self.lazy[u*2+1]+=self.lazy[u] self.lazy[u]=0 self._eval(u*2) self._eval(u*2+1) self.tree[u]=max(self.tree[u*2],self.tree[u*2+1]) n=II() tt=LI() for i in range(n-1):tt[i]-=i*3 st=LazySeg(tt) mn=3*(n-1) for _ in range(II()): l,r,d=MI() st.add(l-1,r,d) print(mn+st.max(0,n-1))