#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 ?????????????????¶?????°?????????(????????????) verified AOJ DSL_2_G, CODEFESTIVAL2015-D
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; //I couldn't "int b=_size".
		if(b<=s||t<=a)return ;
		if(s<=a&&b<=t){
			lazy[num]+=x;	//addition
			
			//dat[num] += x;			//minimum	isn't verified
			//dat[num] += x;			//maximum
			dat[num] += x*(b-a);	//sum
			return ;
		}
		update(s,t,x,num*2+0,a,(a+b)/2);
		update(s,t,x,num*2+1,(a+b)/2,b);
		//dat[num] = lazy[num]+min(dat[num*2],dat[num*2+1]);	//minimum	isn't verified
		//dat[num] = lazy[num]+max(dat[num*2],dat[num*2+1]);	//maximum
		dat[num] = dat[num*2]+dat[num*2+1]+lazy[num]*(b-a);	//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; //I couldn't "int b=_size".
		if(b<=s||t<=a)return _init;
		if(s<=a&&b<=t)return dat[num];
		T l = find(s,t,num*2,a,(a+b)/2);
		T r = find(s,t,num*2+1,(a+b)/2,b);
		//return lazy[num]+min(l,r);					//minimum	isn't verified
		//return lazy[num]+max(l,r);					//maximum
		return l+r+lazy[num]*(min(b,t)-max(a,s));	//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+1,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+1)<<endl;
		}
	}
}
### Prompt

Construct a Cpp code solution to the problem outlined:

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

### Response

```cpp
#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 ?????????????????¶?????°?????????(????????????) verified AOJ DSL_2_G, CODEFESTIVAL2015-D
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; //I couldn't "int b=_size".
		if(b<=s||t<=a)return ;
		if(s<=a&&b<=t){
			lazy[num]+=x;	//addition
			
			//dat[num] += x;			//minimum	isn't verified
			//dat[num] += x;			//maximum
			dat[num] += x*(b-a);	//sum
			return ;
		}
		update(s,t,x,num*2+0,a,(a+b)/2);
		update(s,t,x,num*2+1,(a+b)/2,b);
		//dat[num] = lazy[num]+min(dat[num*2],dat[num*2+1]);	//minimum	isn't verified
		//dat[num] = lazy[num]+max(dat[num*2],dat[num*2+1]);	//maximum
		dat[num] = dat[num*2]+dat[num*2+1]+lazy[num]*(b-a);	//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; //I couldn't "int b=_size".
		if(b<=s||t<=a)return _init;
		if(s<=a&&b<=t)return dat[num];
		T l = find(s,t,num*2,a,(a+b)/2);
		T r = find(s,t,num*2+1,(a+b)/2,b);
		//return lazy[num]+min(l,r);					//minimum	isn't verified
		//return lazy[num]+max(l,r);					//maximum
		return l+r+lazy[num]*(min(b,t)-max(a,s));	//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+1,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+1)<<endl;
		}
	}
}
```