#include <bits/stdc++.h>
using namespace std;
struct node {
  int to, id;
  node(){};
  node(int _to, int _id) : to(_to), id(_id) {}
};
vector<node> q[100000 + 5];
map<int, int> dp[100000 + 5];
int hasval[100000 + 5];
int L, n, Q;
int x[100000 + 5], far[100000 + 5][20];
int Lower_bound(int val) {
  int L = 0, R = n + 1;
  while (L + 1 < R) {
    int mid = (L + R) / 2;
    if (x[mid] <= val)
      L = mid;
    else
      R = mid;
  }
  return L;
}
void prepare() {
  memset(far, -1, sizeof(far));
  for (int i = 1; i <= n; i++) {
    int val = x[i] + L;
    int pos = Lower_bound(val);
    far[i][0] = pos;
  }
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i <= n; i++)
      if (far[i][j - 1] != -1) far[i][j] = far[far[i][j - 1]][j - 1];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d %d", &L, &Q);
  prepare();
  int x, y, log;
  for (log = 1; (1 << log) <= n; log++)
    ;
  log--;
  for (int i = 1; i <= Q; i++) {
    scanf("%d %d", &x, &y);
    if (x > y) swap(x, y);
    int p = x, ans = 0;
    for (int j = log; j >= 0; j--)
      if (far[p][j] != -1 && far[p][j] <= y) {
        ans += (1 << j);
        p = far[p][j];
      }
    printf("%d\n", ans);
  }
  return 0;
}
