#include <bits/stdc++.h>
using namespace std;
struct tree{
long long s,lz;
}tr[400005];
void pushup(int u){
tr[u].s=tr[u*2].s+tr[u*2+1].s;
}
void pushdown(int l,int r,int u){
if (l==r||!tr[u].lz) return ;
tr[u*2].lz+=tr[u].lz;
tr[u*2+1].lz+=tr[u].lz;
int mid=(l+r)/2;
tr[u*2].s+=tr[u].lz*(mid-l+1);
tr[u*2+1].s+=tr[u].lz*(r-mid);
tr[u].lz=0;
}
void build(int l,int r,int u){
if (l==r){
cin >> tr[u].s;
return ;
}
int mid=(l+r)/2;
build(l,mid,u*2);
build(mid+1,r,u*2+1);
pushup(u);
}
void update(int l,int r,int L,int R,int u,long long k){
if (l>=L&&r<=R){
tr[u].lz+=k;
tr[u].s+=(r-l+1)*k;
return ;
}
pushdown(l,r,k);
int mid=(l+r)/2;
if (mid>=L) update(l,mid,L,R,u*2,k);
if (mid<R) update(mid+1,r,L,R,u*2+1,k);
pushup(u);
}
long long getsum(int l,int r,int L,int R,int u){
if (l>=L&&r<=R){
return tr[u].s;
}
pushdown(l,r,u);
long long ans=0;
int mid=(l+r)/2;
if (mid>=L) ans+=getsum(l,mid,L,R,u*2);
if (mid<R) ans+=getsum(mid+1,r,L,R,u*2+1);
return ans;
}
int main(){
int n,m;
cin >> n >> m;
build(1,n,1);
while(m--){
int op;
cin >> op;
if (op==1){
int x,y;
long long k;
cin >> x >> y >> k;
update(1,n,x,y,1,k);
continue;
}
else{
int x,y;
cin >> x >> y;
cout << getsum(1,n,x,y,1) << endl;
continue;
}
}
return 0;
}