import java.io.*;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
public static StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public static PrintWriter cout = new PrintWriter(new OutputStreamWriter(System.out));
public static Scanner sc = new Scanner(System.in);
public static int maxd = 100000+7;
public static int[] a = new int[maxd];
public static int[] tree = new int[maxd*4];
public static int[] lazy = new int[maxd*4];
public static void build(int p,int l,int r){
if(l==r){
tree[p]=a[l];
return ;
}
int mid = (r+l)/2;
build(p*2,l,mid);
build(p*2+1,mid+1,r);
tree[p]=tree[p*2]+tree[p*2+1];
lazy[p]=0;
}
public static void push_down(int p ,int l ,int r ){
if(lazy[p]!=0){
lazy[p*2] += lazy[p];
lazy[p*2+1] += lazy[p];
int mid = (r+l)/2;
tree[p*2] += (mid-l+1) * lazy[p];
tree[p*2+1] += (r-mid) * lazy[p];
lazy[p]=0;
}
}
public static void update(int p,int l,int r,int x,int y,int num){
if(x>r||y<l) return ;
if(x<=l&&r<=y){
lazy[p] += num;
tree[p] += (r-l+1)*num;
return ;
}
push_down(p,l,r);
int mid = (r+l)/2;
update(p*2,l,mid,x,y,num);
update(p*2+1,mid+1,r,x,y,num);
tree[p]=tree[p*2]+tree[p*2+1];
}
public static int query(int p,int l, int r ,int x, int y){
if(x<=l&&r<=y) return tree[p];
if(x>r||y<l) return 0;
push_down(p,l,r);
int mid = (r+l)/2;
int sum = 0;
sum+=query(p*2,l,mid,x,y);
sum+=query(p*2+1,mid+1,r,x,y);
return sum;
}
public static void main(String[] args) throws Exception {
int n = nextInt();
int m = nextInt();
for(int i=1;i<=n;++i) a[i] = nextInt();
build(1,1,n);
for(int i=1;i<=m;++i){
int a1 = nextInt();
if(a1==1) {
int a2 = nextInt();
int a3 = nextInt();
System.out.println(query(1,1,n,a2,a3));
}
else {
int a2 = nextInt();
int a3 = nextInt();
int a4 = nextInt();
update(1,1,n,a2,a3,a4);
}
}
closeAll();
}
public static void cinInit(){
cin.wordChars('a', 'z');
cin.wordChars('A', 'Z');
cin.wordChars(128 + 32, 255);
cin.whitespaceChars(0, ' ');
cin.commentChar('/');
cin.quoteChar('"');
cin.quoteChar('\'');
cin.parseNumbers();
}
public static int nextInt() throws Exception{
cin.nextToken();
return (int) cin.nval;
}
public static long nextLong() throws Exception{
cin.nextToken();
return (long) cin.nval;
}
public static double nextDouble() throws Exception{
cin.nextToken();
return cin.nval;
}
public static String nextString() throws Exception{
cin.nextToken();
return cin.sval;
}
public static void closeAll() throws Exception {
cout.close();
in.close();
out.close();
}
}