#include <bits/stdc++.h>
using namespace std;

#define FOR(_i,_a,_b) for(int _i=_a;_i<=_b;_i++)
#define TCASE int _t;cin>>_t;FOR(_i,1,_t)
#define NFOR(_i,_a,_b) for(int _i=_a;_i>=_b;_i--)
#define pb push_back
#define all(_vec) _vec.begin(),_vec.end()
#define rall(_vec) _vec.rbegin(),_vec.rend()
#define READ(x) freopen(x,"r",stdin);
#define VECTORPRINT(_vec) {int _t=0;while(_t<_vec.size()){cout<<_vec[_t++]<<' ';}}
#define whatis(x) cout<<#x<<"= "<<x<<endl;
#define REP(i, n) for(int i=0;i<n;i++)
#define ARR_SIZE(_arr) sizeof(_arr)/sizeof(_arr[0])
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define bitcount(x) __builtin_popcount(x);
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define most_significant(x) __builtin_clzll (unsigned long long)
#define maxx(a,b) (a>b?a:b)
#define getx getchar_unlocked
#define putx putchar_unlocked

typedef vector<int> vi;
typedef vector<vi > vvi;
typedef vector<pair<int,int> > vpii;
typedef long long lli;
typedef unsigned long long ulli;
typedef vector<lli> vlli;
typedef vector<vector<lli> > matrix;
typedef vector<double> vd;
typedef vector<long double> vld;

int n;
int rootn,sz;
vlli arr;
vlli bsum;
vlli bchange;

void update(){
    lli x,y,k;
    cin>>x>>y>>k; x--; y--;
    int c_l=x/rootn,  c_r=y/rootn;
    if(c_l==c_r){
        for(int i=x ; i<=y ; i++)
            arr[i]+=k;
        bsum[c_l]+=(y-x+1)*k;
    }
    else{
        for(int i=x ; i<=(c_l+1)*rootn-1 && i<=sz-1 ; i++)
            arr[i]+=k;
        bsum[c_l]+=((c_l+1)*rootn-1-x+1)*k;

        for(int i=c_l+1 ; i<=c_r-1 && i<=sz-1; i++){
            bsum[i]+=(lli)rootn*k;
            bchange[i]+= k;
        }

        for(int i=c_r*rootn ; i<=y && i<sz-1; i++)
             arr[i]+=k;
        bsum[c_r]+=(y-c_r*rootn+1)*k;
    }
}

lli getsum(int y){
    int x=0;
    int c_l=0,  c_r=y/rootn;
    lli sum=0;
    if(c_l==c_r)
        for(int i=x ; i<=y ; i++)
            sum+=arr[i]+bchange[c_l];
    else{
        for(int i=x ; i<=(c_l+1)*rootn-1 ; i++)
            sum+=arr[i]+bchange[c_l];
        for(int i=c_l+1 ; i<=c_r-1 ; i++)
            sum+=bsum[i];
        for(int i=c_r*rootn ; i<=y ; i++)
            sum+=arr[i]+bchange[c_r];
    }
    return sum;
}

void printsum(){
    int x,y;
    cin>>x>>y; x--; y--;
    lli maxsum=LLONG_MIN;
    lli tmpsum;
    FOR(i,x,y){
        tmpsum=getsum(i);
        maxsum=maxx(maxsum,tmpsum);
    }
    cout<<maxsum<<endl;
}

void initialise(){
    for(int i=0;i<=n-1;i+=rootn)
        for(int j=i;j<=i+rootn-1;j++)
            if(j<=n-1)
                bsum[(int)i/rootn]+=arr[j];
}

int main(){
    boost
    //freopen("in.txt","r",stdin);
    cin>>n;
    arr.resize(n);
    FOR(i,0,n-1) cin>>arr[i];
    rootn=floor(sqrt(n));
    sz=ceil(sqrt(n));
    bsum.resize(sz);
    bchange.resize(sz);

    initialise();

    int queries,tmp;
    cin>>queries;
    while(queries--){
        cin>>tmp;
        if(tmp==0) update();
        else printsum();
    }

    return 0;
}
