#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e6+10;
long long n,m,a[N],tr[N<<2],mark[N<<2],mark2[N<<2],k,x,y,z;
void build(ll l,ll r,ll p)
{
tr[p]=-1e18;
if(l==r)
{
tr[p]=a[l];
return;
}
ll mid=(l+r)/2;
build(l,mid,p<<1);
build(mid+1,r,p<<1|1);
tr[p]=max(tr[p<<1],tr[p<<1|1]);
}
inline void down(ll p,ll len)
{
if(mark[p]!=-1e18)
{
mark[p*2]=mark[p];
mark[p*2+1]=mark[p];
mark2[p*2]=mark2[p];
mark2[p*2+1]=mark2[p];
tr[p*2+1]=mark[p]+mark2[p];
tr[p*2]=mark[p]+mark2[p];
mark[p]=-1e18;
mark2[p]=0;
}
else
{
mark2[p*2]+=mark2[p];
mark2[p*2+1]+=mark2[p];
tr[p*2]+=mark2[p];
tr[p*2+1]+=mark2[p];
mark2[p]=0;
}
}
void update(ll l,ll r,ll p)
{
if(l>y||r<x)return;
else if(x<=l&&r<=y)
{
if(k==1)mark[p]=z,mark2[p]=0;
else mark2[p]+=z;
if(k==1)tr[p]=z;
else tr[p]+=z;
}
else
{
ll mid=(l+r)>>1;
down(p,r-l+1);
update(l,mid,p<<1);
update(mid+1,r,p<<1|1);
tr[p]=max(tr[p<<1],tr[p<<1|1]);
}
}
ll query(ll l,ll r,ll p)
{
if(l>y||r<x)return -1e18;
if(x<=l&&r<=y)
{
return tr[p];
}
else
{
ll mid=(l+r)/2;
down(p,r-l+1);
return max(query(l,mid,p<<1),query(mid+1,r,p<<1|1));
}
}
int main()
{
scanf("%lld%lld",&n,&m);
for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
build(1,n,1);
for(int i=1;i<=m;i++)
{
scanf("%lld",&k);
if(k!=3)
{
scanf("%lld%lld%lld",&x,&y,&z);
update(1,n,1);
}
else
{
scanf("%lld%lld",&x,&y);
printf("%lld\n",query(1,n,1));
}
}
return 0;
}