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 sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int vec[200002];
int lspa[200002][18];
ll lsum[200002][18];

int rspa[200002][18];
ll rsum[200002][18];

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    for (int i = 0; i < 18; i++) lspa[n+1][i] = n + 1;
    for (int i = 1; i <= n; i++) scanf("%d", &vec[i]);

    for (int i = 1; i <= n; i++) {
        int ne = lower_bound(vec + 1, vec + n + 1, vec[i] + k) - vec;
        lspa[i][0] = ne;
        lsum[i][0] = ne-1;

        ne = upper_bound(vec + 1, vec + n + 1, vec[i] - k) - vec - 1;
        rspa[i][0] = ne;
        rsum[i][0] = ne;    // 얘는 더하고 l은 빠진다.
    }

    for (int j = 1; j < 18; j++) {
        for (int i = 0; i <= n + 1; i++) {
            lspa[i][j] = lspa[lspa[i][j-1]][j-1];
            lsum[i][j] = lsum[i][j-1] + lsum[lspa[i][j-1]][j-1];
            rspa[i][j] = rspa[rspa[i][j-1]][j-1];
            rsum[i][j] = rsum[i][j-1] + rsum[rspa[i][j-1]][j-1];
        }
    }

    int q;
    scanf("%d", &q);
    while (q--) {
        int le, ri;
        scanf("%d %d", &le, &ri);

        int now = le;
        ll ans = ri - le + 1;
        // printf("%lld\n", ans);
        for (int j = 17; j >= 0; j--)
            if (lspa[now][j] <= ri) {
                // printf("%d %d %d : pass\n", now, j, lspa[now][j]);
                ans -= lsum[now][j];
                now = lspa[now][j];
            }
        // printf("%lld\n", ans);

        now = ri;
        for (int j = 17; j >= 0; j--)
            if (rspa[now][j] >= le) {
                ans += rsum[now][j];
                now = rspa[now][j];
            }
        printf("%lld\n", ans);
    }
}


// author: rdd6584