#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define pa pair<int,int>
#define int long long

using namespace std;


struct seg_addsum_getsum{
	//       1
	//   2        3
	// 4   5   6    7
	
	
	private:
	public:
	
	// (1<<15)=32768
	// 1<<16 = 65536
	// 1<<17 = 131072
	// 1<<18 = 262144
	
	int cor=(1<<17);
	
	vector<int> vec;
	vector<int> lazy;
	void shoki1(){
		vec.resize(2*cor+3, 0);
		lazy.resize(2*cor+3, 0);
	}
	void shoki2(){
			for(int i=cor-1;i>0;i--) vec[i]=vec[2*i]+vec[2*i+1];
	}
		
	void chien(int k,int l,int r){
		if(lazy[k]==0) return;
		if(l+1<r){
			lazy[k*2]+=lazy[k]/2;
			lazy[k*2+1]+=lazy[k]/2;
		}
		vec[k]+=lazy[k];
		lazy[k]=0;
	}
	
	void rangeadd(int a,int b,int w, int k=1,int l=0,int r=-3){
		//[a,b)に w加算
		if(r<0) r=cor;
		chien(k,l,r);
		if(a<=l && r<=b){
			lazy[k]+=w*(r-l);
			
			chien(k,l,r);
			return ;
		}
		if(r<=a || b<=l){
			return ;
		}
		
		rangeadd(a,b,w,k*2,l,(l+r)/2);
		rangeadd(a,b,w,k*2+1,(l+r)/2,r);
		vec[k]=vec[2*k]+vec[2*k+1];
		return ;
	}
	
	// [a,b)
	// k-th node
	// k no kukanha [l,r)
	int getsum(int a,int b,int k=1,int l=0,int  r=-3){
		if(r<0) r=cor;
		chien(k,l,r);
		if(a<=l && r<=b){
			return vec[k];
		}
		if(r<=a || b<=l){
			return 0;
		}
		return getsum(a,b,k*2,l,(l+r)/2)+getsum(a,b,k*2+1,(l+r)/2,r);
		
	}
	
	void pre(){
		for(int i=1;i<2*cor;i++){
			cout<<vec[i]<<"/"<<lazy[i]<<" ";
			if(((i+1)&(-(i+1)))==i+1) cout<<endl;
		}
	}
	
};


signed main(){
seg_addsum_getsum SE;
	
	SE.shoki1();
//	for(int i=0;i<SE.cor;i++){
//		SE.vec[i+SE.cor]=i;
//	}
	SE.shoki2();
	
	
	int n,q;
	cin>>n>>q;
	
	for(int i=0;i<q;i++){
	int d,a,b,c;
		cin>>a;
		
		if(a==0){
			cin>>b>>c>>d;
			
			SE.rangeadd(b,c+1,d);
		}
		else{
			cin>>b>>c;
			
			cout<<SE.getsum(b,c+1)<<endl;
		}
	}
	return 0;
}




### Prompt

Your challenge is to write a CPP solution to the following 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

### Response

```cpp
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define pa pair<int,int>
#define int long long

using namespace std;


struct seg_addsum_getsum{
	//       1
	//   2        3
	// 4   5   6    7
	
	
	private:
	public:
	
	// (1<<15)=32768
	// 1<<16 = 65536
	// 1<<17 = 131072
	// 1<<18 = 262144
	
	int cor=(1<<17);
	
	vector<int> vec;
	vector<int> lazy;
	void shoki1(){
		vec.resize(2*cor+3, 0);
		lazy.resize(2*cor+3, 0);
	}
	void shoki2(){
			for(int i=cor-1;i>0;i--) vec[i]=vec[2*i]+vec[2*i+1];
	}
		
	void chien(int k,int l,int r){
		if(lazy[k]==0) return;
		if(l+1<r){
			lazy[k*2]+=lazy[k]/2;
			lazy[k*2+1]+=lazy[k]/2;
		}
		vec[k]+=lazy[k];
		lazy[k]=0;
	}
	
	void rangeadd(int a,int b,int w, int k=1,int l=0,int r=-3){
		//[a,b)に w加算
		if(r<0) r=cor;
		chien(k,l,r);
		if(a<=l && r<=b){
			lazy[k]+=w*(r-l);
			
			chien(k,l,r);
			return ;
		}
		if(r<=a || b<=l){
			return ;
		}
		
		rangeadd(a,b,w,k*2,l,(l+r)/2);
		rangeadd(a,b,w,k*2+1,(l+r)/2,r);
		vec[k]=vec[2*k]+vec[2*k+1];
		return ;
	}
	
	// [a,b)
	// k-th node
	// k no kukanha [l,r)
	int getsum(int a,int b,int k=1,int l=0,int  r=-3){
		if(r<0) r=cor;
		chien(k,l,r);
		if(a<=l && r<=b){
			return vec[k];
		}
		if(r<=a || b<=l){
			return 0;
		}
		return getsum(a,b,k*2,l,(l+r)/2)+getsum(a,b,k*2+1,(l+r)/2,r);
		
	}
	
	void pre(){
		for(int i=1;i<2*cor;i++){
			cout<<vec[i]<<"/"<<lazy[i]<<" ";
			if(((i+1)&(-(i+1)))==i+1) cout<<endl;
		}
	}
	
};


signed main(){
seg_addsum_getsum SE;
	
	SE.shoki1();
//	for(int i=0;i<SE.cor;i++){
//		SE.vec[i+SE.cor]=i;
//	}
	SE.shoki2();
	
	
	int n,q;
	cin>>n>>q;
	
	for(int i=0;i<q;i++){
	int d,a,b,c;
		cin>>a;
		
		if(a==0){
			cin>>b>>c>>d;
			
			SE.rangeadd(b,c+1,d);
		}
		else{
			cin>>b>>c;
			
			cout<<SE.getsum(b,c+1)<<endl;
		}
	}
	return 0;
}




```