#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <list>
#include <string>
#include <cmath>
#include <bitset>
#include<stack>
using namespace std;
using ll = long long;
#define LF(x) fixed << setprecision(x)
typedef pair<int, int> pii;
#define endl "\n"
int n, w[100];
struct node { int l, r, sum, add; }tr[4 * 100];
class Segment_tree {
private:
#define lc p<<1
#define rc p<<1|1
public:
void build(int p, int l, int r) {
tr[p] = { l,r,w[l] };
if (r == l)return;
int m = l + r >> 1;
build(lc, l, m);
build(rc, m + 1, r);
tr[p].sum = tr[lc].sum + tr[rc].sum;
}
int query(int p, int x, int y) {
if (x <= tr[p].l && tr[p].r <= y)
return tr[p].sum;
int m = tr[p].l + tr[p].r >> 1;
pushdown(p);
int sum = 0;
if (x <= m) sum += query(lc, x, y);
if (y > m) sum += query(rc, x, y);
return sum;
}
void pushup(int p) {
tr[p].sum = tr[lc].sum + tr[rc].sum;
}
void pushdown(int p) {
if (tr[p].add) {
tr[lc].sum += tr[p].add * (tr[lc].r - tr[lc].l + 1);
tr[rc].sum += tr[p].add * (tr[rc].r - tr[rc].l + 1);
tr[lc].add += tr[p].add;
tr[rc].add += tr[p].add;
tr[p].add = 0;
}
}
void update(int p, int x, int y, int k) {
if (x <= tr[p].l && tr[p].r <= y) {
tr[p].sum += (tr[p].r - tr[p].l + 1) * k;
tr[p].add += k;
return;
}
int m = tr[p].l + tr[p].r >> 1;
pushdown(p);
if (x <= m) update(lc, x, y, k);
if (y > m) update(rc, x, y, k);
pushup(p);
}
void update(int p, int x, int k) {
if (tr[p].l == x && tr[p].r == x) {
tr[p].sum += k;
return;
}
int m = tr[p].l + tr[p].r >> 1;
if (x <= m)update(lc, x, k);
else update(rc, x, k);
tr[p].sum = tr[lc].sum + tr[rc].sum;
}
};
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m; cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> w[i];
Segment_tree s;
s.build(1,1,n);
for (int i = 0; i < m; i++) {
int q; cin >> q;
if (q == 1) {
int a, b,k; cin >> a >> b>>k;
s.update(1, a, b, k);
}
else {
int a, b; cin >> a >> b;
cout << s.query(1, a, b) << endl;
}
}
return 0;
}