#include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
struct BIT{
    private:
        using Func = function<T(T, T)>;

        int n;
        vector<T> node;

        T init_v;
        Func func;

    public:

        BIT(vector<T> a, Func _func, T _init_v) {
            n = a.size() + 1;
            init_v = _init_v;
            func = _func;

            node.resize(n, init_v);
            for(int i=1; i<n; i++) if((i+(i&-i)) < n) node[i+(i&-i)] = func(node[i+(i&-i)], node[i]);
        }

        BIT() {}

        void add(int pos, T v) {
            while(pos < n){
                node[pos] = func(node[pos], v);
                pos += pos & -pos;
            }
        }

        T sum(int pos){
            T res = init_v;
            while(pos > 0){
                res = func(res, node[pos]);
                pos = pos & (pos-1);
            }
            return res;
        }
};

template<typename T>
struct SecAddBIT{
    private:
        using Func = function<T(T, T)>;
        using MulInt = function<T(T,int)>;
        using Unary = function<T(T)>;
        BIT<T> bit0, bit1;
        Func _add;
        MulInt _mul;
        Unary _inv;

    public:

        SecAddBIT(vector<T> a, Func add_func, MulInt mul_func, Unary inv, T _init_v) {
            int n = a.size();
            _add = add_func;
            _mul = mul_func;
            _inv = inv;
            bit0 = BIT<T>(a, add_func, _init_v);
            bit1 = BIT<T>(vector<T>(n,0), add_func, _init_v);
        }

        void add(int l, int r, T v) {
            bit0.add(l, _mul(_inv(v),l-1));
            bit0.add(r+1, _mul(v,r));
            bit1.add(l, v);
            bit1.add(r+1, _inv(v));
        }

        T sum(int pos){
            return _add(_mul(bit1.sum(pos),pos), bit0.sum(pos));
        }
};

ll add(ll a, ll b){
    return a+b;
}

ll mul(ll a, int b){
    return a*(ll)b;
}

ll inv(ll a){
    return -a;
}

int main(void){
    int n,q; cin >> n >> q;
    SecAddBIT<ll> bit(vector<ll>(n,0), add, mul, inv, 0);

    REP(i,q){
        ll c,s,t; cin >> c >> s >> t;
        if(c){
            ll s1 = bit.sum(t), s2 = bit.sum(s-1);
            cout << s1 - s2 << endl;
        }
        else{
            ll x; cin >> x;
            bit.add(s,t,x);
        }
    }
    return 0;
}


Measured memory_bytes: 5896