#include <bits/stdc++.h>
using namespace std;
int n, m, opt, l, r, k;
long long a[100001];
namespace Tree {
long long res[400001];
long long tag[400001];
int p = 0;
#define ls(r) ((r) << 1)
#define rs(r) (((r) << 1) | 1)
inline int f(int l, int r, int p, long long k) {
tag[p] += k;
res[p] += 1ll * (r - l + 1) * k;
}
inline int push_down(int l, int r, int p) {
int mid = (l + r) / 2;
f(l, mid, ls(p), tag[p]);
f(mid + 1, r, rs(p), tag[p]);
tag[p] = 0;
}
inline int push_up(int p) {
res[p] = res[ls(p)]+ res[rs(p)];
}
inline void build(int p, int l, int r) {
if (l == r) {
res[l] = a[l];
return;
}
int mid = (l + r) >> 1;
build(ls(p), l, mid);
build(rs(p), mid + 1, r);
push_up(p);
}
inline void update(int p, int l, int r, int ql, int qr, long long k) {
if (l >= ql && r <= qr) {
f(l, r, p, k);
return;
}
int mid = (l + r) / 2;
push_down(l, r, p);
if (ql <= mid) update(ls(p), l, mid, ql, qr, k);
if (qr > mid) update(rs(p), mid + 1, r, ql, qr, k);
push_up(p);
}
inline long long query(int p, int l, int r, int ql, int qr) {
if (l >= ql && r <= qr) return res[p];
int mid = (l + r) / 2;
push_down(l, r, p);
long long ans = 0;
if (ql <= mid) ans += query(ls(p), l, mid, ql, qr);
if (qr > mid) ans += query(rs(p), mid + 1, r, ql, qr);
return ans;
}
};
using namespace Tree;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
build(1, 1, n);
while (m--) {
scanf("%d%d%d", &opt, &l, &r);
if (opt == 2) {
printf("%lld\n", query(1, 1, n, l, r));
} else {
scanf("%d", &k);
update(1, 1, n, l, r, k);
}
}
}