注意
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll q[200010],a[200010],sum[200010],sigma[200010];
ll n,f,length;
ll min(ll a,ll b){return a<b?a:b;}
void change(int l,int r,int k)
{
for(int i=l;i<=min(r,q[l]*length);i++)
{
a[i]+=k;
sigma[q[i]]+=k;
}
if(q[l]!=q[r])
for(int i=(q[r]-1)*length+1;i<=r;i++)
{
a[i]+=k;
sigma[q[i]]+=k;
}
for(int i=q[l]+1;i<q[r];i++)
{
sum[i]+=k;
sigma[i]+=k*length;
}
}
ll query(ll l,ll r)
{
ll ans=0;
for(int i=l;i<=min(r,q[l]*length);i++) ans+=a[i]+sum[q[i]];
if(q[l]!=q[r])
for(int i=(q[r]-1)*length+1;i<=r;i++)
ans+=a[i]+sum[q[i]];
for(int i=q[l]+1;i<q[r];i++) ans+=sigma[i];
return ans;
}
int main()
{
scanf("%lld%lld",&n,&f);
length=sqrt(n);
for(int i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
q[i]=(i-1)/length+1;
sigma[q[i]]+=a[i];
}
while(f--)
{
ll op,l,r,x;
scanf("%lld",&op);
if(op==1)
{
scanf("%lld%lld%lld",&l,&r,&x);
change(l,r,x);
}
else if(op==2)
{
scanf("%lld",&x);
change(1,1,x);
}
else if(op==3)
{
scanf("%lld",&x);
change(1,1,-x);
}
else if(op==4)
{
scanf("%lld%lld",&l,&r);
printf("%lld\n",query(l,r));
}
else printf("%lld\n",a[1]+sum[1]);
}
return 0;
}