#include<cstdio>
#define lch (x*2)
#define rch (x*2+1)
using namespace std;
struct ben
{
long long left,right,mark,val;
}tr[400005];
long long a[100005];
void bt(long long x,long long left,long long right)
{
tr[x].left=left;
tr[x].right=right;
if(left==right)
{
tr[x].val=a[left];
return ;
}
long long mid=(left+right)/2;
bt(lch,left,mid);
bt(rch,mid+1,right);
tr[x].val=tr[lch].val+tr[rch].val;
}
void down(long long x)
{
if(tr[x].mark&&tr[x].left<tr[x].right)
{
tr[lch].val+=tr[x].mark*(tr[lch].right-tr[lch].left+1);
tr[lch].mark+=tr[x].mark;
tr[rch].val+=tr[x].mark*(tr[rch].right-tr[rch].left+1);
tr[rch].mark+=tr[x].mark;
}
tr[x].mark=0;
}
void change_interval(long long x,long long left,long long right,long long k)
{
down(x);
if(left<=tr[x].left&&tr[x].right<=right)
{
tr[x].val+=k*(tr[x].right-tr[x].left+1);
tr[x].mark+=k;
return ;
}
long long mid=(tr[x].left+tr[x].right)/2;
if(left<=mid)
{
change_interval(lch,left,right,k);
}
if(right>mid)
{
change_interval(rch,left,right,k);
}
tr[x].val=tr[lch].val+tr[rch].val;
}
long long query_interval(long long x,long long left,long long right)
{
down(x);
if(left<=tr[x].left&&tr[x].right<=right)
{
return tr[x].val;
}
long long ans=0;
long long mid=(tr[x].left+tr[x].right)/2;
if(left<=mid)
{
ans+=query_interval(lch,left,right);
}
if(right>mid)
{
ans+=query_interval(rch,left,right);
}
return ans;
}
int main()
{
long long n,m,pd,x,y,k;
scanf("%lld%lld",&n,&m);
for(long long i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
}
bt(1,1,n);
for(long long i=1;i<=m;i++)
{
scanf("%lld%lld%lld",&pd,&x,&y);
if(pd==1)
{
scanf("%lld",&k);
change_interval(1,x,y,k);
}
else
if(pd==2)
{
printf("%lld\n",query_interval(1,x,y));
}
}
return 0;
}