#include<bits/stdc++.h>
using namespace std;
int a[500001],n,m,ans=0;
int x,y,k,p;
struct q{
long long l,r,sum,lazy;
}tree[500001];
long long maxx(long long a,long long b){
if(a<b)return b;
else return a;
}
inline int read(){
int x=0,f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}
void build(int x,int l,int r){
tree[x].l=l,tree[x].r=r;
if(l==r){tree[x].sum=a[l];return;}
int mid=(l+r)/2;
build(2*x,l,mid),build(2*x+1,mid+1,r);
tree[x].sum=maxx(tree[2*x].sum,tree[2*x+1].sum);
}
void add(int x,int l,int r,int k){
//cout<<x<<" "<<l<<" "<<r<<" "<<k<<endl;
if(tree[x].l>=l&&tree[x].r<=r){
tree[x].lazy+=k;
tree[x].sum+=k;
return;
}
if(tree[x].lazy){
tree[2*x].lazy+=tree[x].lazy;
tree[2*x].sum+=tree[x].lazy;
tree[2*x+1].lazy+=tree[x].lazy;
tree[2*x+1].sum+=tree[x].lazy;
tree[x].lazy=0;
}
int mid=(tree[x].l+tree[x].r)/2;
if(mid>=l)add(2*x,l,r,k);
if(mid+1<=r)add(2*x+1,l,r,k);
tree[x].sum=maxx(tree[2*x].sum,tree[2*x+1].sum);
}
long long get(int x,int l,int r){
if(tree[x].l>=l&&tree[x].r<=r)return tree[x].sum;
if(tree[x].lazy){
tree[2*x].lazy+=tree[x].lazy;
tree[2*x].sum+=tree[x].lazy;
tree[2*x+1].lazy+=tree[x].lazy;
tree[2*x+1].sum+=tree[x].lazy;
tree[x].lazy=0;
}
long long sum=-1e18;
int mid=(tree[x].l+tree[x].r)/2;
if(mid>=l)sum=maxx(sum,get(2*x,l,r));
if(mid+1<=r)sum=maxx(sum,get(2*x+1,l,r));
return sum;
}
int main(){
freopen("max.in","r",stdin);
freopen("max.out","w",stdout);
n=read(),m=read();
for(int i=1;i<=n;i++)a[i]=read();
build(1,1,n);
for(int i=1;i<=m;i++){
cin>>p;
if(p==1){
x=read(),y=read(),k=read();
add(1,x,y,k);
//for(int i=1;i<=9;i++)cout<<tree[i].lazy<<" "<<tree[i].sum<<endl;
}
if(p==2){
x=read(),y=read();
cout<<get(1,x,y)<<endl;
}
}
return 0;
}