#include <bits/stdc++.h>

using namespace std;

#define MAX 100005
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;

const ll MOD = 1000003;

ll st[4 * MAX];
ll lazy[4 * MAX];


void addLazy(ll n, ll b, ll e, ll v) {
	lazy[n] = lazy[n] + v;
	st[n] = st[n] + (v * ( e - b+ 1) );
}

void push(ll n, ll b, ll e) {
	if (b == e)return;

	ll m = (b + e) >> 1;

	addLazy(2 * n, b, m, lazy[n]);
	addLazy(2 * n + 1, m + 1, e, lazy[n]);

	lazy[n] = 0;
}

void update(ll n, ll b, ll e, ll i, ll j, ll v) {
	if (b >= i && e <= j) {
		addLazy(n, b, e, v);
	}
	else if (b > j || e < i) return;
	else {
		push(n, b, e);
		ll m = (b + e) >> 1;
		if (j <= m) {
			update(2 * n, b, m, i, j, v);
		}
		else if (i > m) {
			update(2 * n + 1, m + 1, e, i, j, v);
		}
		else {
			update(2 * n, b, m, i, j, v);
			update(2 * n + 1, m + 1, e, i, j, v);
		}

		st[n] = (st[2 * n] + st[2 * n + 1]);
	}
}

ll query(ll n, ll b, ll e, ll i,ll j){
 
 if(e < i || b > j)
  return 0;
 
 if(b >= i && e <= j)
  return st[n];
  
  push(n,b,e);
  
  ll m = (b + e) >> 1;
  
  ll l = query(2*n,b,m,i,j);
  
  ll r = query(2*n + 1,m + 1,e,i,j);
  
  return l + r;
 
}

int main()
{
	ios_base :: sync_with_stdio(0); cin.tie(0);

 ll N,Q;
 
 cin >> N >> Q;
 
 ll a,b,c,d;
 
 while(Q--){
  
  cin >> a >> b >> c;
  
  if(!a){
   
   cin >> d;
   
   update(1,1,N,b,c,d);
  }
  else{
   
   cout << query(1,1,N,b,c) << endl;
  }
 }

	return 0;
}


