#include <bits/stdc++.h>
#include <cstdio>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N = 1e6 + 10;
inline ll read(){
ll x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9'){
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9'){
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
struct node{
ll l, r;
ll add, pt;
ll maxn;
}tr[N * 4];
int n, m;
ll a[N];
inline void pushup(int p){
tr[p].maxn = max(tr[p * 2].maxn, tr[p * 2 + 1].maxn);
}
inline void build(ll l, ll r, ll p){
tr[p].l = l;
tr[p].r = r;
tr[p].pt = INF;
tr[p].add = 0;
if(l == r){
tr[p].maxn = a[l];
return ;
}
ll mid = (l + r) / 2;
build(l, mid, p * 2);
build(mid + 1, r, p * 2 + 1);
pushup(p);
}
inline void pushdown(int p){
if(tr[p].pt != INF){
tr[p * 2].pt = tr[p * 2 + 1].pt = tr[p].pt;
tr[p * 2].maxn = tr[p * 2 + 1].maxn = tr[p].pt;
tr[p * 2].add = tr[p * 2 + 1].add = tr[p].add = 0 ;
tr[p].pt = INF;
}
if(tr[p].add){
tr[p * 2].add += tr[p].add;
tr[p * 2 + 1].add += tr[p].add;
tr[p * 2 + 1].maxn += tr[p].add;
tr[p * 2].maxn += tr[p].add;
tr[p].add = 0;
}
}
inline void op1(ll l, ll r, ll c, ll p){
if(l <= tr[p].l && r >= tr[p].r){
tr[p].add = 0;
tr[p].pt = c;
tr[p].maxn = c;
return ;
}
pushdown(p);
ll mid = (tr[p].l + tr[p].r) / 2;
if(l <= mid) op1(l, r, c, p * 2);
if(r > m) op1(l, r, c, p * 2 + 1);
pushup(p);
}
inline void op2(ll l, ll r, ll c, ll p){
if(l <= tr[p].l && r >= tr[p].r){
tr[p].maxn += c;
tr[p].add += c;
return ;
}
pushdown(p);
ll mid = (tr[p].l + tr[p].r) / 2;
if(l <= mid) op2(l, r, c, p * 2);
if(r > mid)op2(l, r, c, p * 2 + 1);
pushup(p);
}
inline ll op3(ll l, ll r, ll p){
if(l <= tr[p].l && r >= tr[p].r){
return tr[p].maxn;
}
pushdown(p);
ll mid = (tr[p].l + tr[p].r) / 2;
ll sum = -1e12;
if(l <= mid)sum = 1LL*max(1LL*sum, 1LL*op3(l, r, p * 2));
if(r > mid)sum = 1LL*max(1LL*sum, 1LL*op3(l, r, p * 2 + 1));
return sum;
}
signed main(){
n = read(), m = read();
for(int i = 1; i <= n; i ++ )a[i] = read();
int op, x1, x2, x3;
build(1, n, 1);
for(int i = 1; i <= m; i ++ ){
op = read(), x1 = read(), x2 = read();
if(op == 1){
x3 = read();
op1(x1, x2, x3, 1);
}
if(op == 2){
x3 = read();
op2(x1, x2, x3, 1);
}
if(op == 3){
printf("%lld\n", 1LL*op3(x1, x2, 1));
}
}
return 0;
}