#include<cstdio>
#define lid (id<<1)
#define rid (id<<1|1)
using namespace std;
struct seg_tree
{
int l,r;
int lazy,sum;
}tr[100005*4];
int n,m;
int a[100005],ans[100005],v;
void build(int id,int l,int r)
{
tr[id].l=l;
tr[id].r=r;
if(tr[id].l==tr[id].r)
{
tr[id].sum=a[l];
tr[id].lazy=0;
return;
}
int mid=(l+r)/2;
build(lid,l,mid);
build(rid,mid+1,r);
tr[id].sum=tr[lid].sum+tr[rid].sum;
}
void pushdown(int id)
{
if(tr[id].l!=tr[id].r)
{
tr[lid].lazy+=tr[id].lazy;
tr[rid].lazy+=tr[id].lazy;
tr[lid].sum+=tr[id].lazy*(tr[lid].r-tr[lid].l+1);
tr[rid].sum+=tr[id].lazy*(tr[rid].r-tr[rid].l+1);
tr[id].lazy=0;
}
}
void modity(int id,int l,int r,int val)
{
if(tr[id].l==l && tr[id].r==r)
{
tr[id].lazy+=val;
tr[id].sum+=val*(tr[id].r-tr[id].l+1);
return;
}
int mid=(tr[id].l+tr[id].r)/2;
if(l>mid)modity(rid,l,r,val);
else if(r<=mid)modity(lid,l,r,val);
else modity(lid,l,mid,val),modity(rid,mid+1,r,val);
tr[id].sum=tr[lid].sum+tr[rid].sum;
}
int quety(int id,int l,int r)
{
pushdown(id);
if(tr[id].l==l && tr[id].r==r)
{
return tr[id].sum;
}
int mid=(tr[id].l+tr[id].r)/2;
if(l>mid)return quety(rid,l,r);
else if(r<=mid)return quety(lid,l,r);
else return quety(lid,l,mid)+quety(rid,mid+1,r);
}
int main(void)
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
build(1,1,n);
for(int i=0;i<m;i++)
{
int k;
scanf("%d",&k);
if(k==1)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
modity(1,x,y,z);
}
else
{
int x,y;
scanf("%d%d",&x,&y);
ans[v++]=quety(1,x,y);
}
}
for(int i=0;i<v;i++){printf("%d\n",ans[i]);}
}