#include<bits/stdc++.h>
#define  js  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int maxn=1e5+7;
int a[maxn], gcd[maxn << 2], cha[maxn << 2], sum[maxn << 2];
void pushup(int x) {
    gcd[x]=__gcd( gcd[x<<1], gcd[x<<1|1] );
    cha[x]=max( cha[x<<1],cha[x<<1|1] );
    sum[x]=sum[x<<1]+sum[x<<1|1];
}
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
void build(int l,int r,int rt) {
    if(l==r) {
        gcd[rt]=cha[rt]=abs(sum[rt]=a[l]);
        return;
    }
    int mid=l+r>>1;
    build(lson);
    build(rson);
    pushup(rt);
}//建树 
void update(int pos,int val,int l,int r,int rt) {
    if(l==r) {
        a[l]+=val;
        gcd[rt]=cha[rt]=abs(sum[rt]=a[l]);
        return;
    }
    int mid=l+r>>1;
    if(pos<=mid) update(pos,val,lson);
    else update(pos,val,rson);
    pushup(rt);
}//单点修改
int qsum(int a,int b,int l,int r,int rt) {
    if(a<=l&&b>=r)    return sum[rt];
    int mid=l+r>>1,ans=0;
    if(a<=mid)    ans+=qsum(a,b,lson);
    if(b>mid)    ans+=qsum(a,b,rson);
    return ans;
}//区间求和
int query(int a,int b,int type,int l,int r,int rt) {
    if(a<=l&&b>=r) return type?cha[rt]:gcd[rt];
    int mid=l+r>>1,ans=0;
    if(a<=mid) ans=query(a,b,type,lson);
    if(b>mid) {
        int res=query(a,b,type,rson);
        if(type) ans=max(ans,res);
        else ans=__gcd(ans,res);
    }
    return ans;
}//1求相邻元素的最大差,0求相邻元素的最大公约数 
int n,m;
int main() {
    js;
    cin>>n>>m;
    for(int i=1;i<=n;++i) cin>>a[i];
    for(int i=n;i;--i) a[i]-=a[i-1];
    build(1,n,1);
    for(int i=1,op,l,r,x ;i<=m ;++i) {
        cin>>op;
        if(op==1) {
            cin>>l>>r>>x;
            update(l,x,1,n,1);
            if(r<n) update(r+1,-x,1,n,1);
            continue;
        }
        cin>>l>>r;
        if(op==2) cout<<query(l+1,r,1,1,n,1)<<endl;
        if(op==3)
            cout<<__gcd( qsum(1,l,1,n,1),query(l+1,r,0,1,n,1) )<<endl;
    }
    return 0;
}