#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11, INF = ~0u >> 2;
int n, l, q, dp[20][N], a[N];
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
int bs(int x) {
  int l = 0, r = n - 1;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (a[mid] <= x)
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
int main() {
  n = read();
  for (int i = 0; i < (n); i++) a[i] = read();
  l = read();
  q = read();
  for (int i = 0; i < (n); i++) dp[0][i] = bs(a[i] + l);
  for (int k = 0; k < (19); k++)
    for (int i = 0; i < (n); i++) dp[k + 1][i] = dp[k][dp[k][i]];
  for (int i = 0; i < (q); i++) {
    int a = read(), b = read();
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    for (int j = 19; j >= 0; j--) {
      if (dp[j][a] < b) {
        a = dp[j][a];
        ans += 1 << j;
      }
    }
    printf("%d\n", ans + 1);
  }
  return 0;
}
