#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
#define maxn 100010
#define ll long long
#define lson rt<<1,l,mid
#define rson (rt<<1)|1,mid+1,r
struct node
{
int l,r;
ll sum;
ll flag;
}tree[300010];
int a[maxn];
void pushup(int rt)
{
tree[rt].sum=tree[rt<<1].sum+tree[rt<<1|1].sum;
}
void pushdown(int rt)
{
if(tree[rt].flag)
{
tree[rt<<1].flag+=tree[rt].flag;
tree[rt<<1|1].flag+=tree[rt].flag;
tree[rt<<1].sum+=tree[rt].flag*(tree[rt<<1].r-tree[rt<<1].l+1);
tree[rt<<1|1].sum+=tree[rt].flag*(tree[rt<<1|1].r-tree[rt<<1|1].l+1);
tree[rt].flag=0;
}
}
void build(int rt,int l,int r)
{
tree[rt].l=l;
tree[rt].r=r;
tree[rt].flag=0;
if(l==r)
{
tree[rt].sum=a[l];
return ;
}
int mid=(l+r)>>1;
build(lson);
build(rson);
pushup(rt);
}
void update(int rt,int l,int r,int c)
{
if(l<=tree[rt].l&&tree[rt].r<=r)
{
tree[rt].flag+=c;
tree[rt].sum+=(ll)c*(tree[rt].r-tree[rt].l+1);
return ;
}
pushdown(rt);
int mid=(tree[rt].l+tree[rt].r)>>1;
if(r<=mid)
update(rt<<1,l,r,c);
else
if(l>=mid+1)
{
update(rt<<1|1,l,r,c);
}
else
{
update(rt<<1,l,mid,c);
update(rt<<1|1,mid+1,r,c);
}
pushup(rt);
}
ll query(int rt,int l,int r)
{
if(l<=tree[rt].l&&tree[rt].r<=r)
return tree[rt].sum;
pushdown(rt);
int mid=(tree[rt].l+tree[rt].r)>>1;
ll ans=0;
if(r<=mid)
{
ans+=query(rt<<1,l,r);
}
else
if(l>=mid+1)
ans+=query(rt<<1|1,l,r);
else
{
ans+=query(rt<<1,l,mid);
ans+=query(rt<<1|1,mid+1,r);
}
return ans;
}
int main()
{
int n,q;
//while(scanf("%d%d",&n,&q))
// {
// if(n==0&&q==0) break;
scanf("%d%d",&n,&q);
int i;
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
build(1,1,n);
char ch;
int x,y,z;
while(q--)
{
scanf(" %c",&ch);
if(ch=='Q')
{
scanf("%d%d",&x,&y);
printf("%lld
",query(1,x,y));
}
else
if(ch=='C')
{
scanf("%d%d%d",&x,&y,&z);
update(1,x,y,z);
}
}
//}
return 0;
}