Problem: Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:

* add(s, t, x): add x to as, as+1, ..., at.
* getSum(s, t): report the sum of as, as+1, ..., at.



Note that the initial values of ai (i = 1, 2, . . . , n) are 0.

Constraints

* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 1 ≤ s ≤ t ≤ n
* 0 ≤ x < 1000

Input


n q
query1
query2
:
queryq


In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:


0 s t x


or


1 s t


The first digit represents the type of the query. '0' denotes add(s, t, x) and '1' denotes getSum(s, t).

Output

For each getSum operation, print the sum;

Examples

Input

3 5
0 1 2 1
0 2 3 2
0 3 3 3
1 1 2
1 2 3


Output

4
8


Input

4 3
1 1 4
0 1 4 1
1 1 4


Output

0
4

Solution (in CPP):

Solution:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

//0-index ??????????????°?????????(????????´??°or?????? , ????°????or?????§???or???) verified AOJ DSL_2,DSL_3
template<class T>
class segtree{
private:
	vector<T> dat;
	vector<T> lazy;
	int _size;  //the number of leaves
	T _init;
	
public:
	segtree(int __size=0 , T init=numeric_limits<T>::max() ):_size(__size), _init(init), dat(4*__size,init), lazy(4*__size,init){
		if(__size==0)return ;
		int x=1;
		while(x<_size)x*=2;
		_size = x;
	}
	

	void update(int s,int t, T x ,int num=1,int a=0,int b=-1){
		if(b==-1)b=_size-1; //I couldn't "int b=_size".
		if(b<s||t<a)return ;
		if(s<=a&&b<=t){
			lazy[num]+=x;	//addition
//			lazy[num]=x;	//initialize

//			dat[num] = min(dat[num],x);	//minimum
//			dat[num] = max(dat[num],x);	//maximum
			dat[num]+=x*(b-a+1);		//sum
			return ;
		}
		update(s,t,x,num*2+0,a,(a+b)/2);
		update(s,t,x,num*2+1,(a+b)/2+1,b);
//		dat[num] = min(min(dat[num*2],dat[num*2+1]),lazy[num]);	//minimum
//		dat[num] = max(max(dat[num*2],dat[num*2+1]),lazy[num]);	//maximum
		dat[num] = dat[num*2]+dat[num*2+1]+lazy[num]*(b-a+1);	//sum
	}

	
	// call find(s,t)
	T find(int s,int t,int num=1,int a=0,int b=-1){
		if(b==-1)b=_size-1; //I couldn't "int b=_size".
		if(b<s||t<a)return _init;
		if(s<=a&&b<=t)return dat[num];
		ll l = find(s,t,num*2,a,(a+b)/2);
		ll r = find(s,t,num*2+1,(a+b)/2+1,b);
//		return min(min(l,r),lazy[num]);		//minimum
//		return max(max(l,r),lazy[num]);		//maximum
		return l+r+lazy[num]*(min(b,t)-max(a,s)+1);		//sum
	}

	int size(){return _size;}
};



int main(){
	int n,q;
	cin>>n>>q;
	segtree<ll> st(n,0);
	
	rep(i,q){
		int p;
		cin>>p;
		if(!p){
			int s,t,x;
			cin>>s>>t>>x;
			s--,t--;
			st.update(s,t,x);
//			rep(i,n)cout<<st.find(i,i)<<" ";cout<<endl;
		}else{
			int s,t;
			cin>>s>>t;
			s--,t--;
			cout<<st.find(s,t)<<endl;
		}
	}
}