#include<bits/stdc++.h>
#define maxn 100010
using namespace std;
typedef long long ll;
ll a[maxn],tree[maxn*4];
ll mark[maxn*4];
ll n,m;
void push_down(ll p,ll len){
mark[p*2]+=mark[p];
mark[p*2+1]+=mark[p];
tree[p*2]+=mark[p]*(len-len/2);
tree[p*2+1]+=mark[p]*(len/2);
mark[p]=0;
}
void build(ll l,ll r,ll p){
if(l==r){
tree[p]=a[l];
}
else{
ll M=(l+r)/2;
build(l,M,p*2);
build(M,r,p*2+1);
tree[p]=tree[p*2]+tree[p*2+1];
}
}
void update(ll l,ll r,ll d,ll p,ll cl,ll cr){
if(cl>r||cr<l){
return;
}
else if(cl>=l&&cr<=r){
tree[p]+=(cr-cl+1)*d;
if(cr>cl){
mark[p]+=d;
}
}
else{
ll M=(cl+cr)/2;
push_down(p, cr - cl + 1);
update(l,r,d,p*2,cl,M);
update(l,r,d,p*2+1,M+1,cr);
tree[p]=tree[p*2]+tree[p*2+1];
}
}
ll query(ll l,ll r,ll p,ll cl,ll cr){
if(cl>r||cr<l){
return 0;
}
else if(cl>=l&&cr<=r){
return tree[p];
}
else{
ll M=(cl+cr)/2;
push_down(p,cr-cl+1);
return query(l,r,p*2,cl,M)+query(l,r,p*2+1,M+1,cr);
}
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
build(1,n,1);
for(int i=1;i<=m;i++){
int op,x,y,k;
cin>>op;
if(op==1){
cin>>x>>y>>k;
update(x,y,k,1,1,n);
}
else {
cin>>x>>y;
cout<<query(x,y,1,1,n)<<endl;
}
}
return 0;
}