#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } template struct LazySegmentTree{ using F=function; using G=function; using H=function; private: int sz,height; vector data; vector lazy; // propagate lazy value -> data (node k) inline void propagate(int k){ if(lazy[k]!=OM0){ if(k0;k--) data[k]=f(data[2*k+0],data[2*k+1]); } void update(int a,int b,const OperatorMonoid &x){ update(a,b,x,1,0,sz); } Monoid query(int a,int b){ return query(a,b,1,0,sz); } Monoid operator[](const int &k){ return query(k,k+1); } }; // range add range max using M=ll; using OM=ll; const M M1=-LINF; const OM OM0=0; M segf(M a,M b){ return (a>b?a:b); } M segg(M a,OM b){ return a+b; } OM segh(OM a,OM b){ return a+b; } signed main(){ int n;cin>>n; vector t(n-1); cin>>t; rep(i,n) t[i]-=(3ll)*i; LazySegmentTree seg(n,segf,segh,segg,0ll,0ll); rep(i,n) seg.set(i,t[i]); seg.build(); int q;cin>>q; while(q--){ int l,r;ll d;cin>>l>>r>>d;l--; seg.update(l,r,d); ll mx=seg.query(0,n); cout<<(3*(n-1)+mx)<<"\n"; } return 0; }