#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
#include <iterator>
#pragma GCC optimize("O3,Ofast,unroll-loops")
using namespace std;
using VI = vector<long>;

long n, l, step;
long xs[101010];
VI stepdays[101010];

void calc_times(long v) {
    long cnt = 0;
    long cur = v;
    for (long i = cur + 1; i < n; i++) {
        if (xs[i] - xs[cur] <= l) {
            if (i + 10000 < n && xs[i + 10000] - xs[cur] <= l) {
              i += 10000;
              continue;
            }
            if (i + 5000 < n && xs[i + 5000] - xs[cur] <= l) {
              i += 5000;
              continue;
            }
            if (i + 2500 < n && xs[i + 2500] - xs[cur] <= l) {
              i += 2500;
              continue;
            }
            if (i + 1200 < n && xs[i + 1200] - xs[cur] <= l) {
              i += 1200;
              continue;
            }
            if (i + 500 < n && xs[i + 500] - xs[cur] <= l) {
              i += 500;
              continue;
            }
            if (i + 200 < n && xs[i + 200] - xs[cur] <= l) {
              i += 200;
              continue;
            }
            if (i + 100 < n && xs[i + 100] - xs[cur] <= l) {
              i += 100;
              continue;
            }
            if (i + 50 < n && xs[i + 50] - xs[cur] <= l) {
              i += 50;
              continue;
            }
            if (i + 20 < n && xs[i + 20] - xs[cur] <= l) {
              i += 20;
              continue;
            }
            if (i + 10 < n && xs[i + 10] - xs[cur] <= l) {
              i += 10;
              continue;
            }
            if (i + 5 < n && xs[i + 5] - xs[cur] <= l) {
              i += 5;
              continue;
            }
            if (i + 2 < n && xs[i + 2] - xs[cur] <= l) {
              i += 2;
              continue;
            }
        } else {
            cnt++;
            i--;
            cur = i;
            if (cnt % step == 0) {
                stepdays[v].push_back(cur);
                if (stepdays[cur].size()) {
                  for (long j: stepdays[cur]) {
                    stepdays[v].push_back(j);
                  }
                  return;
                }
            }
        }
    }
}

long get_days(long left, long right) {
    if (left == right) {
        return 0;
    }
    if (xs[right] - xs[left] <= l) {
        return 1;
    }
    long ret = 0;
    long cur = left;
    for (long i = left + 1; i <= right; i++) {
        if (xs[i] - xs[cur] <= l) {
            if (i + 10000 < right && xs[i + 10000] - xs[cur] <= l) {
              i += 10000;
              continue;
            }
            if (i + 5000 < right && xs[i + 5000] - xs[cur] <= l) {
              i += 5000;
              continue;
            }
            if (i + 2500 < right && xs[i + 2500] - xs[cur] <= l) {
              i += 2500;
              continue;
            }
            if (i + 1200 < right && xs[i + 1200] - xs[cur] <= l) {
              i += 1200;
              continue;
            }
            if (i + 500 < right && xs[i + 500] - xs[cur] <= l) {
              i += 500;
              continue;
            }
            if (i + 200 < right && xs[i + 200] - xs[cur] <= l) {
              i += 200;
              continue;
            }
            if (i + 100 < right && xs[i + 100] - xs[cur] <= l) {
              i += 100;
              continue;
            }
            if (i + 50 < right && xs[i + 50] - xs[cur] <= l) {
              i += 50;
              continue;
            }
            if (i + 20 < right && xs[i + 20] - xs[cur] <= l) {
              i += 20;
              continue;
            }
            if (i + 10 < right && xs[i + 10] - xs[cur] <= l) {
              i += 10;
              continue;
            }
            if (i + 5 < right && xs[i + 5] - xs[cur] <= l) {
              i += 5;
              continue;
            }
            if (i + 2 < right && xs[i + 2] - xs[cur] <= l) {
              i += 2;
              continue;
            }
            if (i == right) {
                return ret + 1;
            }
        } else {
            ret++;
            i--;
            cur = i;
        }
    }
    cout << "ERROR" << endl;
    exit(1);
}

void init() {
    step = sqrt(n);
    for (long i = n - 2; i >= 0; i--) {
        calc_times(i);
    }
}

long query(long left, long right) {
    long i;
    for (i = 0; i < stepdays[left].size(); i++) {
        if (stepdays[left][i] > right) break;
    }
    if (i == 0) {
        return get_days(left, right);
    } else {
        return i * step + get_days(stepdays[left][i - 1], right);
    }
}

int main() {
    cin >> n;
    for (long i = 0; i < n; i++) {
        cin >> xs[i];
    }
    cin >> l;

    init();

    long q;
    cin >> q;
    for (long i = 0; i < q; i++) {
        long a, b;
        cin >> a >> b;
        a--;
        b--;

        cout << query(min(a, b), max(a, b)) << endl;
    }
}


Measured memory_bytes: 188544