#include<bits/stdc++.h>
using namespace std;
const int N=2e5+1000;
#define ll long long
ll n,f,a[N],len,s[5000],add[5000];
ll get(ll i){
return i/len;
}
void solove(ll x,ll y,ll d){
if(get(x)==get(y)){
for(ll i=x;i<=y;i++){
a[i]+=d,s[get(i)]+=d;
}
return;
}
ll i=x,j=y;
while(get(i)==get(x)){
a[i]+=d;
s[get(i)]+=d;
i++;
}
while(get(j)==get(y)){
a[j]+=d;
s[get(j)]+=d;
j--;
}
for(ll k=get(i);k<=get(j);k++){
s[k]+=len*d;
add[k]+=d;
}
}
ll ask(ll x,ll y){
ll res=0;
if(get(x)==get(y)){
for(ll i=x;i<=y;i++)
res+=a[i]+add[get(i)];
return res;
}
ll i=x,j=y;
while(get(i)==get(x)){
res+=a[i]+add[get(i)];
i++;
}
while(get(j)==get(y)){
res+=a[j]+add[get(j)];
j--;
}
for(ll k=get(i);k<=get(j);k++){
res+=s[k];
}
return res;
}
int main(){
cin>>n>>f;
for(ll i=1;i<=n;i++)
scanf("%lld",&a[i]);
len=sqrt(n);
while(f--){
ll op,x,y,k;
scanf("%lld",&op);
if(op==1){
scanf("%lld%lld%lld",&x,&y,&k);
solove(x,y,k);
}else if(op==2){
scanf("%lld",&k);
a[1]+=k;
s[get(1)]+=k;
}else if(op==3){
scanf("%lld",&k);
a[1]-=k;
s[get(1)]-=k;
}else if(op==4){
scanf("%lld%lld",&x,&y);
printf("%lld\n",ask(x,y));
}else if(op==5){
printf("%lld\n",a[1]+add[get(1)]);
}
}
}