//sum:区间加和
//add懒标记:父亲+自己已加,孩子要加未加,父亲裂开时要加。
//使用add, add = 0, 子++,子标记。
//接收add: 自add+=add(继承标记!!!)
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
typedef long long L;
int n,m,d;
int x,y;
L w[N];
struct A {
int l,r;
L sum,add;
}tr[4*N];
void pushup(int u) {
tr[u].sum = tr[u<<1].sum + tr[u<<1|1].sum;
}
void pushdown(int u) {
if(tr[u].add) {
tr[u<<1].add += tr[u].add;
tr[u<<1|1].add += tr[u].add;
tr[u<<1].sum += (tr[u<<1].r - tr[u<<1].l+1)*tr[u].add;
tr[u<<1|1].sum += (tr[u<<1|1].r - tr[u<<1|1].l+1)*tr[u].add;
tr[u].add = 0;
}
}
void build(int u,int l,int r) {
if(l==r) {
tr[u] = {l,l,w[l],0};
}
else {
tr[u] = {l,r};
int m = l + r >> 1;
build(u<<1,l,m);build(u<<1|1,m+1,r);
pushup(u);
}
}
L query(int u,int l,int r) {
if(tr[u].l >= l && tr[u].r<=r) {
return tr[u].sum;
}
else {
int m = tr[u].l + tr[u].r >> 1;
pushdown(u);
L s = 0;
if(l<=m) s = query(u<<1,l,r);
if(m<r) s+=query(u<<1|1,l,r);
pushup(u);
return s;
}
}
void modity(int u,int l,int r, L c) {
if(tr[u].l>=l&&tr[u].r<=r) {
tr[u].sum += (tr[u].r - tr[u].l + 1)*c;
tr[u].add+=c;
}
else {
int m = tr[u].r + tr[u].l>>1;
pushdown(u);
if(l<=m) modity(u<<1,l,r,c);
if(m<r) modity(u<<1|1,l,r,c);
pushup(u);
}
}
int main() {
cin>>n>>m;
for(int i = 1; i <= n; ++i) cin>>w[i];
build(1,1,n);
while(m--) {
char c;
cin>>c;
if(c=='C') {
cin>>x>>y>>d;
modity(1,x,y,d);
}
else {
cin>>x>>y;
cout<<query(1,x,y)<<endl;
}
}
}