#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<cstdlib>
#define LL long long
using namespace std;
const int constant=1e5+5;
LL tree[constant],n,m,a[constant],tag[constant];
LL ll(LL x){return x<<1;}
LL rr(LL x){return x<<1|1;}
LL push_up(LL x){ return tree[ll(x)]+tree[rr((x))];}
void build(LL p,LL l,LL r){
if(l==r){
tree[p]=a[l];
return ;
}
LL mid=l+r>>1;
build(ll(p),l,mid);
build(rr(p),mid+1,r);
push_up(p);
}
void push_down(LL p,LL l,LL r){
LL mid=l+r>>1;
tag[ll(p)]+=tag[p];
tag[rr(p)]+=tag[p];
tree[ll(p)]+=tag[p]*(mid-l+1);
tree[rr(p)]+=tag[p]*(r-mid);
tag[p]=0;
}
LL query(LL p,LL l,LL r,LL L,LL R){
if(L<=l&&r<=R) return tree[p];
LL mid=l+r>>1,sum=0;
push_down(p,l,r);
if(mid>=L) sum+=query(ll(p),l,mid,L,R);
if(mid<R) sum+=query(rr(p),mid+1,r,L,R);
return sum;
}
void revise(LL p,LL l,LL r,LL L,LL R,LL k){
if(l>=L&&r<=R){
tag[p]+=k;
tree[p]+=k*(r-l+1);
return ;
}
LL mid=l+r>>1;
push_down(p,l,r);
if(mid>=l){
revise(ll(p),l,mid,L,R,k);
}
if(mid<R){
revise(rr(p),mid+1,r,L,R,k);
}
push_up(p);
}
int main(){
scanf("%lld%lld",&n,&m);
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
build(1,1,n);
while(m--){
LL op;
scanf("%lld",&op);
if(op==1){
LL x,y,k;
scanf("%lld%lld%lld",&x,&y,&k);
revise(1,1,n,x,y,k);
}
else{
LL x,y;
scanf("%lld%lld",&x,&y);
printf("%lld\n",query(1,1,n,x,y));
}
}
return 0;
}