//对于操作1,明显就是维护一下差分数组bi
//对于操作2,推公式可以得出:=∑(1~x)∑(1~i)bj = ∑(1~x)bi * (x + 1)- ∑(1~x)i * bi
//所以只要维护两个前缀和:bi 和 ibi 就好了
#include<bits/stdc++.h>
#define lowbit(x) x & -x
using namespace std;
typedef long long ll;
const int N = 2e5 + 10, inf = 0x3f3f3f3f;
int n, m;
ll a[N], d[N];
ll tr1[N], tr2[N];//tr1是bi前缀和,tr2是i*bi的前缀和
void add(ll id, ll x, ll tr[])
{
for(int i = id; i <= n; i += lowbit(i)) tr[i] += x;
}
ll sum(ll tr[], ll x)
{
ll res = 0;
for(int i = x; i; i -= lowbit(i)) res += tr[i];
return res;
}
ll qurry(ll x)
{
return sum(tr1, x) * (x + 1) - sum(tr2, x);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> m;
for(int i = 1; i <= n; i ++) cin >> a[i];
for(int i = n; i; i --) d[i] = a[i] - a[i - 1], add(i, d[i], tr1), add(i, i * d[i], tr2);
while(m --)
{
char c;
cin >> c;
if(c == 'C')
{
ll l, r, x;
cin >> l >> r >> x;
add(l, x, tr1), add(r + 1, -x, tr1);
add(l, l * x, tr2), add(r + 1, -x * (r + 1), tr2);
}
else
{
ll l, r;
cin >> l >> r;
cout << qurry(r) - qurry(l - 1) << '\n';
}
}
return 0;
}