#include <bits/stdc++.h>
using namespace std;
int N;
int X[100010];
int L;
int Q;
pair<int, int> querys[100010];
int parent[400][100010];
long long powlong(long long x, int i) {
  long long ret = 1;
  long long temp = x;
  while (i != 0) {
    if (i & 1) ret *= temp;
    temp *= temp;
    i = i >> 1;
  }
  return ret;
}
int bsearch(int a, int b, int k) {
  if (k == -1) {
    return 0;
  }
  if (parent[k][a] == -1 || parent[k][a] > b) {
    return bsearch(a, b, k - 1);
  } else {
    return powlong(2, k) + bsearch(parent[k][a], b, k - 1);
  }
}
int main() {
  scanf("%d", &N);
  for (int cnt = 0; cnt < (N); ++cnt) {
    int x;
    scanf("%d", &x);
    X[cnt] = x;
  }
  scanf("%d%d", &L, &Q);
  for (int cnt = 0; cnt < (Q); ++cnt) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    if (a > b) swap(a, b);
    querys[cnt] = pair<int, int>(a, b);
  }
  for (int i = 0; i < N; ++i) {
    int j = lower_bound(X, X + N, X[i] + L + 1) - X - 1;
    parent[0][i] = j;
  }
  parent[0][N - 1] = -1;
  for (int j = 1; j < 400; ++j) {
    for (int i = 0; i < N; ++i) {
      if (parent[j - 1][i] == -1) {
        parent[j][i] = -1;
      } else {
        parent[j][i] = parent[j - 1][parent[j - 1][i]];
      }
    }
  }
  for (int cnt = 0; cnt < (Q); ++cnt) {
    pair<int, int> p = querys[cnt];
    printf("%d\n", bsearch(p.first, p.second, 399));
  }
  return 0;
}
