package SloveQuestion;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
public class P2357 {
public static StreamTokenizer cin=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public static PrintWriter cout=new PrintWriter(new OutputStreamWriter(System.out));
public static int nextInt() throws IOException
{
cin.nextToken();
return (int) cin.nval;
}
public static long nextLong() throws IOException
{
cin.nextToken();
return (long) cin.nval;
}
private static int maxn=(int) (2e5+10);
private static long a[]=new long[maxn];
private static long t[]=new long[maxn<<2];
private static void build(int k, int L, int R) {
if(L==R)
{
lazy[k]=0;
t[k]=a[L];
}
else
{
int m=L+((R-L)>>1);
lazy[k]=0;
build(k<<1,L,m);
build(k<<1|1,m+1,R);
PushUp(k);
}
}
private static void PushUp(int k)
{
t[k]=t[k<<1]+t[k<<1|1];
}
private static long lazy[]=new long[maxn<<2];
private static void PushDown(int k,int l,int r)
{
if(lazy[k]!=0)
{
lazy[k<<1]+=lazy[k];
lazy[k<<1|1]+=lazy[k];
int mid=l+((r-l)>>1);
t[k<<1]+=(mid-l+1)*lazy[k];
t[k<<1|1]+=(r-mid)*lazy[k];
lazy[k]=0;
}
}
private static void update(int l, int r, long v, int L, int R, int k) {
if(l<=L&&r>=R)
{
lazy[k]+=v;
t[k]+=(R-L+1)*v;return ;
}
else
{
PushDown(k,L,R);
int m=L+((R-L)>>1);
if(l<=L)
{
update(l,r,v,L,m,k<<1);
}
if(r>R)
{
update(l,r,v,m+1,R,k<<1|1);
}
PushUp(k);return ;
}
}
private static long query(int l, int r, int L, int R, int k) {
if(l<=L&&r>=R)
{
return t[k];
}
long ans=0;
PushDown(k,L,R);
int mid=L+((R-L)>>1);
if(l<=mid)
ans+=query(l,r,L,mid,k<<1);
if(r>mid)
ans+=query(l,r,mid+1,R,k<<1|1);
return ans;
}
public static void main(String[] args) throws IOException
{
int n,m;
n=nextInt();m=nextInt();
for(int i=1;i<=n;i++)a[i]=nextLong();
build(1,1,n);
int key;
int l,r;int v;
for(int i=1;i<=m;i++)
{
key=nextInt();
if(key==1)
{
l=nextInt();r=nextInt();v=nextInt();
update(l,r,v,1,n,1);
}
else if(key==2)
{
v=nextInt();;
update(1,1,v,1,n,1);
}
else if(key==3)
{
v=nextInt();
update(1,1,-v,1,n,1);
}
else if(key==4)
{
l=nextInt();r=nextInt();
cout.println(query(l,r,1,n,1));
}
else if(key==5)
{
cout.println(query(1,1,1,n,1));
}
}
cout.flush();cout.close();return ;
}
}