//出现RE后,将数组大小开大,就好了。
//把int改为long long 就由WA变为AC了
//区间更新 //参见 https://blog.youkuaiyun.com/SSL_ZYC/article/details/81940902 http://kenby.iteye.com/blog/962159
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
#define lowbit(x) (x&(-x)) //计算2^k
typedef long long LL;
const int Max = 500000+5;
LL c[Max];//c[i] = a[i – 2^k + 1] + … + a[i],k为i在二进制下末尾0的个数
LL c1[Max];
void Update(LL *c, int x, int y, int MAX)
{
while(x <= MAX){
c[x] += y;
x += lowbit(x);
}
}
LL Sum(LL *c, LL x)
{
LL sum = 0;
while(x > 0){
sum += c[x];
x -= lowbit(x);
}
return sum;
}
void SumSQ(int y, int x)
{
int sum = 0;
while(y > 0){
sum += c[y];
y -= lowbit(y);
}
while(x > 0){
sum -= c[x];
x -= lowbit(x);
}
// cout << sum << endl;
printf("%d\n", sum);
}
int main()
{
LL T, cnt = 1;
string s;
//cin >> T;
{
LL N, t;
// cin >> N;
scanf("%lld%lld", &N, &t);
memset(c, 0, sizeof(c));
for(LL i=1; i<=N; i++){
LL x;
// cin >> x;
scanf("%lld", &x);
Update(c, i, x, N);
}
// cout << "Case " << cnt++ << ":" << endl;
// printf("Case %d:\n", cnt++);
// while(cin >> s && s != "End"){
while(t--){
cin >> s;
LL x, y, num;
// cin >> x >> y;
if(s == "C"){
scanf("%lld%lld%lld", &x, &y, &num);
Update(c, x, -num*(x-1), N);
Update(c, y+1, num*y, N);
Update(c1, x, num, N);
Update(c1, y+1, -num, N);
}
else if(s == "Q"){
scanf("%lld%lld", &x, &y);
long long ans = 0;
ans += Sum(c, y) + Sum(c1, y)*y;
ans -= Sum(c, x-1) + Sum(c1, x-1)*(x-1);//区间求和
printf("%lld\n", ans);
// SumSQ(y, x-1);
// cout << Sum(y)-Sum(x-1) << endl;
}
}
}
return 0;
}