import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
static long[] sum;
static long[] adds;
public static void build(int n){
sum = new long[n<<2];
adds = new long[n<<2];
}
public static void getSum(int rt){
sum[rt]=sum[rt<<1]+sum[rt<<1|1];
}
public static void ms(int[] nums,int l,int r,int rt){
if (l==r){
sum[rt] = nums[l];
return;
}
int mid = (l+r)>>1;
ms(nums,l,mid,rt<<1);
ms(nums,mid+1,r,rt<<1|1);
getSum(rt);
}
public static void update(int rt ,int ln,int rn){
if (adds[rt]!=0) {
adds[rt<<1]+=adds[rt];
sum[rt<<1]+=(adds[rt]*ln);
adds[rt<<1|1] += adds[rt];
sum[rt<<1|1] += (adds[rt]*rn);
adds[rt] = 0;
}
}
public static void add(int L ,int R,int K,int l,int r,int rt) {
if (L <= l&& R >= r){
sum[rt] += K*(r-l+1);
adds[rt]+=K;
return;
}
int mid = (r+l)>>1;
update(rt,mid-l+1,r-mid);
if (mid>=L){
add(L,R,K,l,mid,rt<<1);
}
if (mid<R){
add(L,R,K,mid+1,r,rt<<1|1);
}
getSum(rt);
}
static long ans;
public static long get(int L,int R,int l,int r,int rt){
ans = 0;
if (l<=L&&r<=R){
return sum[rt];
}
int mid = (r+l)>>1;
update(rt,mid-l+1,r-mid);
if (mid>=L){
ans+=get(L, R, l, mid, rt << 1);
}
if (mid<R){
ans+=get(L, R, mid + 1, r, rt << 1 | 1);
}
return ans;
}
public static void main(String[] args) throws IOException {
// Input sc = new Input();
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
int n = sc.nextInt();
int f = sc.nextInt();
int[] nums = new int[n+1];
for (int i = 1; i <= n ; i++) {
nums[i] = sc.nextInt();
}
build(n);
ms(nums,1,n,1);
for (int i = 0; i < f; i++) {
int op =sc.nextInt();
if (op==1){
int l=sc.nextInt();
int r =sc.nextInt();
int c =sc.nextInt();
add(l,r,c,1,n,1);
}else if (op==2){
int c =sc.nextInt();
add(1,1,c,1,n,1);
}else if (op==3){
int c =sc.nextInt();
add(1,1,-c,1,n,1);
}else if (op==4){
int l=sc.nextInt();
int r=sc.nextInt();
System.out.println(get(l, r, 1, n, 1));
}else {
System.out.println(get(1,1,1,n,1));
}
}
}
static class Input{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StreamTokenizer in = new StreamTokenizer(br);
public int nextInt() throws IOException {
in.nextToken();
return (int) in.nval;
}
}
}