#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+10;
const int inf=-1e18;
int a[N];
int n,m;
struct node
{
int tag_add,tag_cover,maxn,l,r;
}t[N<<2];
int read()
{
int x=0,f=1;char c=getchar();
while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
return x*f;
}
void up(int p)
{
t[p].maxn=max(t[p<<1].maxn,t[p<<1|1].maxn);
}
void tag_cover_down(int p)
{
if(t[p].tag_cover!=inf)
{
t[p<<1].tag_add=t[p<<1|1].tag_add=0;
t[p<<1].maxn=t[p<<1|1].maxn=t[p].tag_cover;
t[p<<1].tag_cover=t[p<<1|1].tag_cover=t[p].tag_cover;
t[p].tag_cover=inf;
}
}
void tag_add_down(int p)
{
if(t[p].tag_add)
{
tag_cover_down(p);
t[p<<1].maxn+=t[p].tag_add;
t[p<<1|1].maxn+=t[p].tag_add;
t[p<<1].tag_add+=t[p].tag_add;
t[p<<1|1].tag_add+=t[p].tag_add;
t[p].tag_add=0;
}
return ;
}
void down(int p)
{
tag_cover_down(p);
tag_add_down(p);
return ;
}
void build(int p,int l,int r)
{
t[p].l=l,t[p].r=r;
if(l==r)
{
t[p].maxn=a[l];
t[p].tag_cover=inf;
t[p].tag_add=0;
return ;
}
int mid=(l+r)>>1;
build(p<<1,l,mid);
build(p<<1|1,mid+1,r);
up(p);
}
void tag_add_add(int p,int l,int r,int w)
{
if(t[p].l>=l&&t[p].r<=r)
{
tag_cover_down(p);
t[p].maxn+=w;
t[p].tag_add+=w;
return ;
}
down(p);
int mid=(t[p].l+t[p].r)>>1;
if(l<=mid) tag_add_add(p<<1,l,mid,w);
if(r>mid) tag_add_add(p<<1|1,mid+1,r,w);
up(p);
}
void tag_cover_add(int p,int l,int r,int w)
{
if(t[p].l>=l&&t[p].r<=r)
{
t[p].tag_add=0;
t[p].maxn=w;
t[p].tag_cover=w;
return ;
}
down(p);
int mid=(t[p].l+t[p].r)>>1;
if(l<=mid) tag_cover_add(p<<1,l,mid,w);
if(r>mid) tag_cover_add(p<<1|1,mid+1,r,w);
up(p);
}
int query(int p,int l,int r)
{
if(t[p].l>=l&&t[p].r<=r)
{
return t[p].maxn;
}
down(p);
int mid=(t[p].l+t[p].r)>>1;
int res=inf;
if(l<=mid) res=max(res,query(p<<1,l,mid));
if(r>mid) res=max(res,query(p<<1|1,mid+1,r));
return res;
}
signed main()
{
n=read(),m=read();
for(int i=1;i<=n;i++)
a[i]=read();
build(1,1,n);
for(int i=1;i<=n*4;i++)
t[i].tag_cover=inf;
for(int i=1;i<=m;i++)
{
int op=read();
int l=read(),r=read();
if(op==1)
{
int x=read();
tag_cover_add(1,l,r,x);
}
else if(op==2)
{
int x=read();
tag_add_add(1,l,r,x);
}
else if(op==3)
{
printf("%lld\n",query(1,l,r));
}
}
return 0;
}