#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<map>
#include<iomanip>
#include<math.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define lowbit(x) x&(-x)
const int N=2e5+10;
ll c1[N],c2[N],n,m,q,i,a[N];
ll sum[N];
void add(ll x,ll d,ll *c)
{
for(;x<=n;x+=lowbit(x))
{
c[x]+=d;
}
}
ll ask(ll x,ll *c)
{
ll sum=0;
for(;x>0;x-=lowbit(x))
{
sum+=c[x];
}
return sum;
}
int main()
{
char op[3];
ll x,y,d;
scanf("%lld %lld",&n,&q);
memset(c1,0,sizeof c1);
memset(c2,0,sizeof c2);
for(i=1; i<=n; ++i)
{
scanf("%lld",sum+i);
sum[i]+=sum[i-1];
}
while(q--)
{
scanf("%s",op);
if(op[0] == 'C')
{
scanf("%lld%lld%lld",&x,&y,&d);
add(x,d,c1);
add(y+1,-d,c1);
add(x,x*d,c2);
add(y+1,-(y+1)*d,c2);
}
else
{
scanf("%lld %lld",&x,&y);
printf("%lld\n",sum[y]-sum[x-1]+ask(y,c1)*(y+1)-ask(x-1,c1)*x-ask(y,c2)+ask(x-1,c2));
}
}
return 0;
}