#include <cstring>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int maxn = 100001;struct cnode{ int l, r; long long nsum, inc; cnode *pleft, *pright;};int n, q, ncount;cnode tree[maxn * 3];void buildtree(cnode *proot, int s, int e){ proot->l = s; proot->r = e; proot->inc = 0; proot->nsum = 0; if (s != e) { ncount++; proot->pleft = tree + ncount; ncount++; proot->pright = tree + ncount; buildtree(proot->pleft, s, (s + e) / 2); buildtree(proot->pright, (s + e) / 2 + 1, e); }}void insert(cnode *proot, int s, int e, long long increase){ int mid; if (s > proot->r || e < proot->l) return; s = max(s, proot->l); e = min(e, proot->r); mid = (proot->l + proot->r) / 2; if (s == proot->l && e == proot->r) { proot->inc += increase; return; } proot->nsum += (e - s + 1) * increase; insert(proot->pleft, s, e, increase); insert(proot->pright, s, e, increase);}long long query(cnode *proot, int s, int e){ int mid; if (s > proot->r || e < proot->l) return 0; s = max(s, proot->l); e = min(e, proot->r); mid = (proot->l + proot->r) / 2; if (proot->l == s && proot->r == e) return proot->nsum + proot->inc * (proot->r - proot->l + 1); long long inc_value = proot->inc * (e - s + 1); return query(proot->pleft, s, e) + query(proot->pright, s, e) + inc_value;}int main(){ int i, h, s, e; char ch; scanf("%d%d", &n, &q); ncount = 0; buildtree(tree, 1, n); for (i = 0; i < n; i++) { scanf("%d", &h); insert(tree, i + 1, i + 1, h); } for (i = 0; i < q; i++) { getchar(); scanf("%c", &ch); if (ch == 'C') { scanf("%d%d%d", &s, &e, &h); insert(tree, s, e, h); } else { scanf("%d%d", &s, &e); printf("%lldn", query(tree, s, e)); } } return 0;}