/*
线段树-成段更新:裸题,成段增减,区间求和
注意:开long long:)
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
#define LL long long
const int MAXN = 1e5 + ;
const int INF = 0x3f3f3f3f;
struct Node
{
LL sum, add;
}node[MAXN << ];
void push_up(int rt)
{
node[rt].sum = node[rt<<].sum + node[rt<<|].sum;
}
void push_down(int rt, int c)
{
if (node[rt].add)
{
node[rt<<].add += node[rt].add;
node[rt<<|].add += node[rt].add;
node[rt<<].sum += node[rt].add * (c - (c >> ));
node[rt<<|].sum += node[rt].add * (c >> );
node[rt].add = ;
}
}
void build(int l, int r, int rt)
{
node[rt].add = ;
if (l == r) {scanf ("%I64d", &node[rt].sum); return ;}
int mid = (l + r) >> ;
build (lson); build (rson);
push_up (rt);
}
void updata(int ql, int qr, int c, int l, int r, int rt)
{
if (ql <= l && r <= qr) {node[rt].sum += (LL) c * (r - l + ); node[rt].add += c; return ;}
push_down (rt, r - l + );
int mid = (l + r) >> ;
if (ql <= mid) updata (ql, qr, c, lson);
if (qr > mid) updata (ql, qr, c, rson);
push_up (rt);
}
LL query(int ql, int qr, int l, int r, int rt)
{
if (ql <= l && r <= qr) return node[rt].sum;
push_down (rt, r - l + );
int mid = (l + r) >> ; LL ans = ;
if (ql <= mid) ans += query (ql, qr, lson);
if (qr > mid) ans += query (ql, qr, rson);
return ans;
}
int main(void) //POJ 3468 A Simple Problem with Integers
{
//freopen ("POJ_3468.in", "r", stdin);
int n, q;
while (scanf ("%d%d", &n, &q) == )
{
build (, n, );
while (q--)
{
char s[]; int ql, qr, c;
scanf ("%s", &s);
if (s[] == 'Q')
{
scanf ("%d%d", &ql, &qr);
printf ("%I64d\n", query (ql, qr, , n, ));
}
else
{
scanf ("%d%d%d", &ql, &qr, &c);
updata (ql, qr, c, , n, );
}
}
}
return ;
}