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>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<db> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

int a[200001],ne[200001][18],pr[200001][18];
ll Ls[200001][18],Rs[200001][18];
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	fup(i,1,n,1)scanf("%d",a+i);
	int t=1;
	fup(i,1,n,1){
		while(t<=n && a[t]-a[i]<k)t++;
		ne[i][0]=t;
	}
	t=n;
	fdn(i,n,1,1){
		while(t>=0 && a[i]-a[t]<k)t--;
		pr[i][0]=t;
	}
	fup(j,0,16,1){
		fup(i,1,n,1){
			if(ne[i][j]<=n)ne[i][j+1]=ne[ne[i][j]][j];
			if(pr[i][j]>0)pr[i][j+1]=pr[pr[i][j]][j];
		}
	}
	fup(i,1,n,1){
		Ls[i][0]=-(i-1);
		Rs[i][0]=i;
	}
	fup(j,0,16,1){
		fup(i,1,n,1){
			if(ne[i][j]<=n)Ls[i][j+1]=Ls[i][j]+Ls[ne[i][j]][j];
			if(pr[i][j]>0)Rs[i][j+1]=Rs[i][j]+Rs[pr[i][j]][j];
		}
	}
	int q;
	scanf("%d",&q);
	while(q--){
		int l,r;
		scanf("%d%d",&l,&r);
		int now=l;
		int cnt=0;
		fdn(j,17,0,1){
			if(ne[now][j]>0 && ne[now][j]<=r){
				cnt+=1<<j;
				now=ne[now][j];
			}
		}
		cnt++;
		ll ans=0;
		fdn(j,17,0,1){
			if(cnt&(1<<j)){
				ans+=Ls[l][j]+Rs[r][j];
				l=ne[l][j],r=pr[r][j];
			}
		}
		printf("%lld\n",ans);
	}
}