#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long Hashimoto = 0;
  bool Kanna = 1;
  char I_Love = getchar();
  while (I_Love < '0' || I_Love > '9') {
    if (I_Love == '-') Kanna = 0;
    I_Love = getchar();
  }
  while (I_Love >= '0' && I_Love <= '9') {
    Hashimoto = Hashimoto * 10 + I_Love - '0';
    I_Love = getchar();
  }
  return (Kanna ? Hashimoto : -Hashimoto);
}
template <typename T1, typename T2>
inline void Umax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T1, typename T2>
inline void Umin(T1 &a, T2 b) {
  if (a > b) a = b;
}
int n;
int d[111111];
int rd[111111];
int a[20][111111];
int b[20][111111];
void solve(int x, int y) {
  int ans = 0;
  for (int i = 19; i >= 0; i--) {
    if (a[i][x] < y) {
      ans += 1 << i;
      x = a[i][x];
    } else if (a[i][x] == y) {
      ans += 1 << i;
      break;
    }
  }
  printf("%d\n", ans);
}
void solve2(int x, int y) {
  int ans = 0;
  for (int i = 19; i >= 0; i--) {
    if (b[i][x] > y) {
      ans += 1 << i;
      x = b[i][x];
    } else if (b[i][x] == y) {
      ans += 1 << i;
      break;
    }
  }
  printf("%d\n", ans);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  n = read();
  for (int i = 0; i < (n); ++i) {
    d[i] = read();
    rd[i] = -d[i];
  }
  reverse(rd, rd + n);
  int L = read();
  d[n] = 2 * (int)1e9;
  for (int i = 0; i < (n); ++i) {
    a[0][i] = upper_bound(d, d + n, d[i] + L) - d - 1;
  }
  for (int i = 0; i < (20); ++i) {
    a[i][n - 1] = n - 1;
  }
  for (int j = 0; j < (19); ++j)
    for (int i = 0; i < (n); ++i) {
      a[j + 1][i] = a[j][a[j][i]];
    }
  int q = read();
  while (q--) {
    int x = read() - 1, y = read() - 1;
    if (x < y)
      solve(x, y);
    else
      solve(y, x);
  }
  return 0;
}
