#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
const int N=1e5+5;
int a[N],tree[N*4],tag[N*4],n,m,op,x,y,k;
void pushup(int idx){
tree[idx]=tree[idx*2]+tree[idx*2+1];
}
void pushdown(int idx,int l,int r){
if(!tag[idx]) return;
int m=(l+r)/2;
tree[idx*2]+=tag[idx]*(m-l+1);
tag[idx*2]+=tag[idx];
tree[idx*2+1]+=tag[idx]*(r-m);
tag[idx*2+1]+=tag[idx];
tag[idx]=0;
}
void build(int idx,int l,int r){
if(l==r){
tree[idx]=a[l];
return;
}
int m=(l+r)/2;
build(idx*2,l,m);
build(idx*2+1,m+1,r);
pushup(idx);
}
void update(int idx,int l,int r,int x,int y,int k){
if(x>=l&&y<=r){
tree[idx]+=k*(r-l+1);
tag[idx]+=k;
return;
}
pushdown(idx,l,r);
int m=(l+r)/2;
if(x<=m) update(idx*2,l,m,x,y,k);
if(y>m) update(idx*2+1,m+1,r,x,y,k);
pushup(idx);
}
int query(int idx,int l,int r,int x,int y){
if(x<=l&&y>=r) return tree[idx];
pushdown(idx,l,r);
int m=(l+r)/2,ans=0;
if(x<=m) ans+=query(idx*2,l,m,x,y);
if(y>m) ans+=query(idx*2+1,m+1,r,x,y);
return ans;
}
signed main(){
ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>a[i];
build(1,1,n);
while(m--){
cin>>op>>x>>y;
if(op==1){
cin>>k;
update(1,1,n,x,y,k);
}else{
cout<<query(1,1,n,x,y)<<endl;
}
}
return 0;
}