#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+10;
struct tree{
int l,r,sum,add;
}t[4*N];
int n,q;
int a[N];
inline void build(int pos,int l,int r){
t[pos].l=l,t[pos].r=r;
if(l==r){
t[pos].sum=a[l];
return ;
}else{
int mid=(l+r)>>1;
int left=pos<<1;
int right=pos<<1|1;
build(left,1,mid);
build(right,mid+1,r);
t[pos].sum=t[left].sum+t[right].sum;
}
}
void pushdown(int pos){
int left=pos<<1,right=pos<<1|1;
auto &root= t[pos],&ll=t[left],&rr=t[right];
if(root.add!=0){
ll.add+=root.add;
ll.sum+=(ll.r-ll.l+1)*root.add;
rr.add+=root.add;
rr.sum+=(rr.r-rr.l+1)*root.add;
root.add=0;
}
}
inline void update2(int pos,int x,int y,int k){
int l=t[pos].l,r=t[pos].r,mid=(l+1)>>1;
if(x<=l&&y>=r){
t[pos].sum+=(r-l+1)*k;
t[pos].add+=k;
}else{
pushdown(pos);
int left=pos<<1,right=pos<<1|1;
if(x<=mid){
update2(left,x,y,k);
}
if(y>=mid){
update2(right,x,y,k);
}
t[pos].sum=t[left].sum+t[right].sum;
}
}
inline int getmax(int pos,int x,int y){
int l=t[pos].l,r=t[pos].r,mid=(l+r)>>1;
if(x<=l&&y>=r){
return t[pos].sum;
}
pushdown(pos);
int ans=0,left=pos*2,right=pos*2+1;
if(x<=mid){
ans+=getmax(left,x,y);
}
if(y>mid){
ans+=getmax(right,x,y);
}
return ans;
}
signed main(){
scanf("%lld%lld",&n,&q);
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
build(1,1,n);
while(q--){
int op;
scanf("%lld",&op);
if(op==1){
int x,y,d;
scanf("%lld%lld%lld",&x,&y,&d);
update2(1,x,y,d);
}else if(op==2){
int x,y;
scanf("%lld%lld",&x,&y);
printf("%lld\n",getmax(1,x,y));
}
}
return 0;
}