#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXS=100000;
int n,m,ipt[MAXS+2];
/*------------------------------------*/
struct node{
ll l,r,val,lazy;
}tree[(MAXS<<2)+100];
inline ll ls(ll n) {return n<<1;}
inline ll rs(ll n) {return n<<1|1;}
inline ll read()
{
char ch=getchar();
int x=0,f=1;
while(ch < '0' || ch > '9')
{
if(ch == '-')
f = -1;
ch = getchar();
}
while('0' <= ch && ch <= '9')
{
x = (x<<3) + (x<<1) + (ch^48);
ch = getchar();
}
return x * f;
}
void build(ll n,ll l,ll r)
{
tree[n].l=l;
tree[n].r=r;
tree[n].lazy=0;
if (l==r)
{
tree[n].val=ipt[n];
return;
}
ll mid=l+r>>1;
build(ls(n),l,mid);
build(rs(n),mid+1,r);
tree[n].val=tree[ls(n)].val+tree[rs(n)].val;
}
void pushdown(ll p)
{
if (tree[p].lazy)
{
tree[ls(p)].lazy+=tree[p].lazy;
tree[ls(p)].val+=tree[p].lazy*(tree[ls(p)].r-tree[ls(p)].l+1);
tree[rs(p)].lazy+=tree[p].lazy;
tree[rs(p)].val+=tree[p].lazy*(tree[rs(p)].r-tree[rs(p)].l+1);
tree[p].lazy=0;
}
}
void change(ll p,ll l,ll r,ll v)
{
if (tree[p].l>=l and tree[p].r<=r)
{
tree[p].val+=v*(tree[p].r-tree[p].l+1);
tree[p].lazy+=v;
return;
}
ll mid=tree[p].l+tree[p].r>>1;
pushdown(p);
if (l<=mid)
change(ls(p),l,r,v);
if (r>mid)
change(rs(p),l,r,v);
tree[p].val=tree[ls(p)].val+tree[rs(p)].val;
}
ll ask(ll p,ll l,ll r)
{
if (tree[p].l>=l and tree[p].r<=r)
return tree[p].val;
pushdown(p);
ll mid=tree[p].l+tree[p].r>>1;
ll ans=0;
if (l<=mid) ans+=ask(ls(p),l,r);
if (r>mid) ans+=ask(rs(p),l,r);
return ans;
}
/*------------------------------------*/
int main()
{
n=read();m=read();
for (int i=1;i<=n;i++)
{
ipt[i]=read();
}
build(1,1,n);
for (int i=1;i<=m;i++)
{
int op=read();
if (op==1)
{
int x=read(),y=read(),k=read();
change(1,x,y,k);
}
else
{
int x=read(),y=read();
cout<<ask(1,x,y)<<endl;
}
}
return 0;
}