Problem: There are N points on a number line, i-th of which is placed on coordinate X_i. These points are numbered in the increasing order of coordinates. In other words, for all i (1 \leq i \leq N-1), X_i < X_{i+1} holds. In addition to that, an integer K is given.

Process Q queries.

In the i-th query, two integers L_i and R_i are given. Here, a set s of points is said to be a good set if it satisfies all of the following conditions. Note that the definition of good sets varies over queries.

* Each point in s is one of X_{L_i},X_{L_i+1},\ldots,X_{R_i}.
* For any two distinct points in s, the distance between them is greater than or equal to K.
* The size of s is maximum among all sets that satisfy the aforementioned conditions.



For each query, find the size of the union of all good sets.

Constraints

* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq 10^9
* 0 \leq X_1 < X_2 < \cdots < X_N \leq 10^9
* 1 \leq Q \leq 2 \times 10^5
* 1 \leq L_i \leq R_i \leq N
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N K
X_1 X_2 \cdots X_N
Q
L_1 R_1
L_2 R_2
\vdots
L_Q R_Q


Output

For each query, print the size of the union of all good sets in a line.

Examples

Input

5 3
1 2 4 7 8
2
1 5
1 2


Output

4
2


Input

15 220492538
4452279 12864090 23146757 31318558 133073771 141315707 263239555 350278176 401243954 418305779 450172439 560311491 625900495 626194585 891960194
5
6 14
1 8
1 13
7 12
4 12


Output

4
6
11
2
3

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	bool neg=0;
	while(!(c>='0' && c<='9')){
		if(c=='-') neg=1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return neg?-ret:ret;
}
void putint(LL v){
	if(v<0){
		putchar('-');
		v=-v;
	}
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
int n,D,x[200005],q;
struct tree{
	int fa[20][200005],val[200005],sum[200005];
	tree(){
		memset(fa,-1,sizeof(fa));
		memset(val,0,sizeof(val));
	}
	void prec(bool rev){
		int i,j,k;
		for(i=1;i<20;++i){
			for(j=0;j<n;++j){
				if(~fa[i-1][j])
					fa[i][j]=fa[i-1][fa[i-1][j]];
				else
					fa[i][j]=-1;
			}
		}
		if(rev){
			for(i=n-1;i>=0;--i){
				sum[i]=val[i]+(~fa[0][i]?sum[fa[0][i]]:0);
			}
		}
		else{
			for(i=0;i<n;++i){
				sum[i]=val[i]+(~fa[0][i]?sum[fa[0][i]]:0);
			}
		}
	}
	int qry(int v,int tv){
//		printf("qry %d %d\n",v,tv);
		int ret=sum[v],i;
		for(i=19;i>=0;--i){
			if(~fa[i][v] && val[fa[i][v]]>=tv)
				v=fa[i][v];
		}
//		printf("got to %d\n",v);
		return ret-(~fa[0][v]?sum[fa[0][v]]:0);
	}
}R2L,L2R;
int main(){
	int i,j,k;
	n=readint();D=readint();
	for(i=0;i<n;++i) x[i]=readint();
	for(i=0;i<n;++i) R2L.val[i]=i,L2R.val[i]=-i+1;
	for(i=j=0;i<n;++i){
		while(x[i]-x[j]>=D) ++j;
		R2L.fa[0][i]=j-1;
	}
	for(i=j=n-1;i>=0;--i){
		while(x[j]-x[i]>=D) --j;
		L2R.fa[0][i]=(j==n-1?-1:j+1);
	}
	R2L.prec(0);
	L2R.prec(1);
	q=readint();
	while(q--){
		int l=readint()-1,r=readint()-1;
		printf("%d\n",R2L.qry(r,l)+L2R.qry(l,-r+1));
	}
	return 0;
}
/*
 * 代码框架
 * 1. 实现树结构体，自行设置父亲、权值，支持定位祖先并求权值和
 * 2. 向左走->下标，向右走->下标相反数
*/