#include <bits/stdc++.h>
using namespace std;
struct segt {
  long long l, r, sum, tg;
} tree[400010];
long long a[100010];
void push_down(long long i) {
  if (tree[i].tg) {
    tree[i * 2].sum += tree[i].tg * (tree[i * 2].r - tree[i * 2].l + 1);
    tree[i * 2 + 1].sum +=
        tree[i].tg * (tree[i * 2 + 1].r - tree[i * 2 + 1].l + 1);
    tree[i * 2].tg += tree[i].tg;
    tree[i * 2 + 1].tg += tree[i].tg;
    tree[i].tg = 0;
  }
}
void build(long long le, long long ri, long long i) {
  tree[i].l = le;
  tree[i].r = ri;
  tree[i].tg = 0;
  if (le == ri) {
    tree[i].sum = a[le];
    return;
  }
  long long mid = (le + ri) >> 1;
  build(le, mid, i * 2);
  build(mid + 1, ri, i * 2 + 1);
  tree[i].sum = tree[i * 2].sum + tree[i * 2 + 1].sum;
}
void add(long long le, long long ri, long long i, long long k) {
  if (le <= tree[i].l && ri >= tree[i].r) {
    tree[i].sum += k * (tree[i].r - tree[i].l + 1);
    tree[i].tg += k;
    return;
  }
  push_down(i);
  if (tree[i * 2].r >= le) add(le, ri, i * 2, k);
  if (tree[i * 2 + 1].l <= ri) add(le, ri, i * 2 + 1, k);
  tree[i].sum = tree[i * 2].sum + tree[i * 2 + 1].sum;
}
long long ask(long long le, long long ri, long long i) {
  if (le <= tree[i].l && ri >= tree[i].r) return tree[i].sum;
  push_down(i);
  long long cnt = 0;
  if (tree[i * 2].r >= le) cnt += ask(le, ri, i * 2);
  if (tree[i * 2 + 1].l <= ri) cnt += ask(le, ri, i * 2 + 1);
  return cnt;
}
signed main() {
  long long n, m, i, o, x, y, k;
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  build(1, n, 1);
  while (m--) {
    cin >> o;
    if (o == 1) {
      cin >> x >> y >> k;
      add(x, y, 1, k);
    } else {
      cin >> x >> y;
      cout << ask(x, y, 1) << endl;
    }
  }
  return 0;
}
