#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
int t,ll,rr,kk;
struct node{
int s;
int l,r;
int lan=0;
}tree[100000];
int ans=0;
void down(int n){
tree[n*2].lan+=tree[n].lan;
tree[n*2+1].lan+=tree[n].lan;
tree[n*2].s+=(tree[n*2].r-tree[n*2].l+1)*tree[n].lan;
tree[n*2+1].s+=(tree[n*2+1].r-tree[n*2+1].l+1)*tree[n].lan;
tree[n].lan=0;
}
void build(int l,int r,int n){
tree[n].l=l;
tree[n].r=r;
if(l==r){
cin >>tree[n].s;
return;
}
build(l,(l+r)/2,n*2);
build((l+r)/2+1,r,n*2+1);
tree[n].s=tree[n*2].s+tree[n*2+1].s;
}
void qjcx(int l, int r,int n){
if(ll<=tree[n].l&&tree[n].r<=rr){
ans+=tree[n].s;
return;
}
if(ll<=(l+r)/2)qjcx(l,(l+r)/2,n*2);
if(rr>(l+r)/2)qjcx((l+r)/2+1,r,n*2+1);
}
void qjxg(int l, int r,int n){
if(ll<=tree[n].l&&tree[n].r<=rr){
tree[n].s+=((r-l)+1)*kk;
tree[n].lan+=kk;
return;
}
if(tree[n].lan)down(n);
if(ll<=(l+r)/2)qjcx(l,(l+r)/2,n*2);
if(rr>(l+r)/2)qjcx((l+r)/2+1,r,n*2+1);
tree[n].s=tree[n*2].s+tree[n*2+1].s;
}
int n,m;
int main(){
cin >>n>>m;
build(1,n,1);
// for(int i=1;i<=n*4;i++){
// cout <<i<<":["<<tree[i].l<<" "<<tree[i].r<<"]"<<tree[i].s<<endl;
// }
for(int i=1;i<=m;i++){
ans=0;
cin >>t;
if(t==1){
cin >>ll>>rr>>kk;
qjxg(1,n,1);
}else{
cin >>ll>>rr;
qjcx(1,n,1);
cout <<ans<<endl;
}
}
return 0;
}