#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  int l, q;
  cin >> l >> q;
  vector<int> a(q), b(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<vector<int>> r, r2;
  vector<int> temp(n), ex(n);
  int j = 1;
  for (int i = 0; i < n - 1; i++) {
    while ((x[i] + l >= x[j]) * (j < n)) {
      j++;
    }
    temp[i] = j - 1;
  }
  temp[n - 1] = n - 1;
  r.push_back(temp);
  int flag = 1;
  int count = 1;
  while (flag) {
    flag = 0;
    ex = temp;
    temp = vector<int>(n, 0);
    for (int i = 0; i < n; i++) {
      temp[i] = ex[ex[i]];
      if (temp[i] != n - 1) {
        flag = 1;
      }
    }
    r.push_back(temp);
    count++;
  }
  count--;
  r2 = vector<vector<int>>(n, vector<int>(count, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < count; j++) {
      r2[i][j] = r[j][i];
    }
  }
  vector<int> sp(count);
  sp[0] = 1;
  for (int i = 1; i < count; i++) {
    sp[i] = sp[i - 1] * 2;
  }
  for (int i = 0; i < q; i++) {
    int ans = 0;
    int start = a[i];
    int goal = b[i];
    if (a[i] > b[i]) {
      start = b[i];
      goal = a[i];
    }
    while (1) {
      int add = upper_bound(r2[start].begin(), r2[start].end(), goal) -
                r2[start].begin();
      add--;
      ans += sp[add];
      start = r2[start][add];
      if (start == goal) break;
    }
    cout << ans << endl;
  }
  return 0;
}
