#include<iostream>
#define ll long long
using namespace std;
const int MAX = 1e5 + 5;
ll n, m, k, sign, x, y;
bool isFirst = true;
ll sum[4 * MAX], change[4 * MAX];
ll num[MAX];
void build(ll l, ll r, ll idx) {
if (l == r) {
sum[idx] = num[l];
return;
}
ll mid = (l + r) / 2;
build(l, mid, idx << 1);
build(mid + 1, r, idx << 1 | 1);
sum[idx] = sum[idx << 1] + sum[idx << 1 | 1];
}
void lazyUpdate(ll l, ll r, ll idx) {
if (change[idx] == 0)return;
ll mid = (l + r) / 2;
change[idx << 1] += change[idx];
sum[idx << 1] += (mid - l + 1) * change[idx];
change[idx << 1 | 1] += change[idx];
sum[idx << 1 | 1] += (r - mid ) * change[idx];
change[idx] = 0;
}
void update(ll targetL, ll targetR, ll l, ll r, ll idx) {
if (targetL<=l && targetR>=r) {
change[idx] += k;
sum[idx] += (r - l + 1) * k;
return;
}
//向下一层执行更新
lazyUpdate(l, r, idx);
ll mid = (l + r) / 2;
if (targetL <= mid)update(targetL, targetR, l, mid, idx << 1);
if (targetR > mid)update(targetL, targetR, mid + 1, r, idx << 1 | 1);
sum[idx] = sum[idx << 1] + sum[idx << 1 | 1];
}
long long res(ll targetL, ll targetR, ll l, ll r, ll idx) {
if (targetL <= l && r <= targetR)return sum[idx];
else {
lazyUpdate(l, r, idx);
long long ans = 0;
ll mid = (l + r) / 2;
if (targetL <= mid)ans += res(targetL, targetR, l, mid, idx << 1);
if (targetR > mid)ans += res(targetL, targetR, mid + 1, r, idx << 1 | 1);
return ans;
}
}
int main()
{
ios::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> num[i];
}
//建树
build(1, n, 1);
//轮询
for (int i = 1; i <= m;i++) {
cin >> sign;
if (sign == 1) {
cin >> x >> y >> k;
update(x, y, 1, n, 1);
}
else {
cin >> x >> y;
if (isFirst)isFirst = false;
else cout << '\n';
cout<< res(x, y, 1, n, 1);
}
}
return 0;
}