#include <cstdio>
#include <algorithm>
#include <iostream>
#define ls L,M,rt<<1
#define rs M+1,R,rt<<1|1
using namespace std;
typedef long long ll;
const int maxn = 111110;
ll tree[maxn<<2];
ll add[maxn<<2];
void pushup(int rt)
{
tree[rt]=tree[rt<<1]+tree[rt<<1|1];
}
void pushdo(int rt,int L,int R)
{
if(add[rt])
{
add[rt<<1]+=add[rt];
add[rt<<1|1]+=add[rt];
int M=(L+R)>>1;
tree[rt<<1]+=(M-L+1)*add[rt];
tree[rt<<1|1]+=(R-M)*add[rt];
add[rt]=0;
}
}
void build(int L,int R,int rt)
{
add[rt]=0;
if(L==R)
{
scanf("%I64d",&tree[rt]);
return;
}
int M=((R+L)>>1);
build(ls);
build(rs);
pushup(rt);
}
void update(int l,int r,int L,int R,int rt,int c)
{
if(l<=L&&R<=r)
{
add[rt]+=c;
tree[rt]+=(ll)c*(R-L+1);
return ;
}
pushdo(rt,L,R);
int M=((R+L)>>1);
if(r<=M) update(l,r,ls,c);
else if(l>M) update(l,r,rs,c);
else update(l,M,ls,c),update(M+1,r,rs,c);
pushup(rt);
}
ll query(int l,int r,int L,int R,int rt)
{
if(l<=L&&R<=r)
return tree[rt];
pushdo(rt,L,R);
int M=((R+L)>>1);
ll res=0;
if(r<=M) return query(l,r,ls);
else if(l>M) return query(l,r,rs);
else return query(l,M,ls)+query(M+1,r,rs);
return res;
}
int main()
{
int n,q;
cin>>n>>q;
build(1,n,1);
while(q--)
{
char op[3];
scanf("%s",op);
if(op[0]=='Q')
{
int a,b;
scanf("%d%d",&a,&b);
printf("%I64d\n",query(a,b,1,n,1));
}
else
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
update(a,b,1,n,1,c);
}
}
return 0;
}
#include"stdio.h"
#include"string.h"
#define M (L+R)/2
#define rs M+1,R,((p<<1)|1)
#define ls L,M,(p<<1)
typedef long long ll;
const int maxn=110000;
ll sum[maxn<<2];
ll add[maxn<<2];
void pushUp(int p)
{
sum[p]=sum[p<<1]+sum[p<<1|1];
}
void pushDown(int L,int R,int p)
{
if(add[p])
{
add[p<<1]+=add[p];
add[p<<1|1]+=add[p];
sum[p<<1]+=add[p]*(M-L+1);
sum[p<<1|1]+=add[p]*(R-M);//(R-(M+1)+1);
add[p]=0;
}
}
void build(int L,int R,int p)
{
if(L==R) {scanf("%lld",sum+p);return;}
build(ls);
build(rs);
pushUp(p);
}
void update(int l,int r,int L,int R,int p,int c)
{
if(l<=L&&R<=r) {sum[p]+=(R-L+1)*c;add[p]+=c;return;}
pushDown(L,R,p);
if(l<=M) update(l,r,ls,c);
if(r>M) update(l,r,rs,c);
pushUp(p);
}
ll query(int l,int r,int L,int R,int p)
{
if(l<=L&&R<=r) return sum[p];
pushDown(L,R,p);
ll ans=0;
if(l<=M) ans+=query(l,r,ls);
if(r>M) ans+=query(l,r,rs);
return ans;
}
int main()
{
int N,Q;
int i,j;
while(scanf("%d%d",&N,&Q)==2)
{
build(1,N,1);
char a[2];
memset(add,0,sizeof(add));
for(i=1;i<=Q;i++)
{
scanf("%s",a);
if(a[0]=='Q')
{
int s,t;
scanf("%d%d",&s,&t);
printf("%I64d\n",query(s,t,1,N,1));
}
else
{
int s,t,c;
scanf("%d%d%d",&s,&t,&c);
update(s,t,1,N,1,c);
}
}
}
return 0;
}