include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
typedef long long LL;
const int N = 100010;
int tr_1[N], a[N];
LL tr_2[N];
int n, m;
inline int lowbit(int x)
{
return x & (-x);
}
void add(int x, int num)
{
for(int i = x; i <= n; i += lowbit(i))
{
tr_1[i] += num;
tr_2[i] += (LL)num * x;
}
}
LL sum(int x)
{
LL res = 0;
for(int i = x; i > 0; i -= lowbit(i))
{
res += (tr_1[i] * (x + 1));
res -= tr_2[i];
}
return res;
}
int main()
{
scanf(“%d%d”, &n, &m);
for(int i = 1; i <= n; i)scanf(“%d”, &a[i]);
for(int i = 1; i <= n; i)
{
add(i, a[i] - a[i-1]);
}
while(m–)
{
char op[2];
int l, r, d;
scanf(“%s”, op);
if(op[0] == ‘Q’)
{
scanf(“%d%d”, &l, &r);
LL res = sum(r) - sum(l - 1);
cout << res << endl;
}
else
{
scanf(“%d%d%d”, &l, &r, &d);
add(l, d);
add(r + 1, -d);
}
}
return 0;
}