#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) x&-x
long long n,m,tree1[10000000],tree2[10000000],a,x,y,k,temp;
long long sum1(long long x){
long long ans=0;
while(x){
ans+=tree1[x];
x-=lowbit(x);
}
return ans;
}
long long sum2(long long x){
long long ans=0;
while(x){
ans+=tree2[x];
x-=lowbit(x);
}
return ans;
}
void update1(long long x,long long d){
while(x<=n){
tree1[x]+=d;
x+=lowbit(x);
}
}
void update2(long long x,long long d){
while(x<=n){
tree2[x]+=d;
x+=lowbit(x);
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>m;
long long num=0;
for(long long i=1;i<=n;i++){
cin>>temp;
update1(i,temp-num);
update2(i,(i-1)*(temp-num));
num=temp;
}
for(long long i=1;i<=m;i++){
long long q,l,r,d;
cin>>q;
if(q==1){
cin>>l>>r>>d;
update1(l,d);
update1(r+1,-d);
update2(l,(l-1)*d);
update2(r+1,r*(-d));
}
else{
cin>>l>>r;
printf("%lld\n",(r*sum1(r)-(l-1)*sum1(l-1))-(sum2(r)-sum2(l-1)));
}
}
return 0;
}