#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
const int LOG = 20;
int a[N];
int nxt[N][20];
int main() {
  int n, L;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &L);
  for (int i = 0; i < n; ++i) {
    nxt[i][0] = upper_bound(a.begin(), a.end(), a[i] + L) - a.begin() - 1;
  }
  for (int j = 1; j < LOG; ++j) {
    for (int i = 0; i < n; ++i) {
      nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
    }
  }
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    if (x > y) {
      swap(x, y);
    }
    int step = 0;
    for (int i = LOG - 1; i >= 0; --i) {
      if (nxt[x][i] <= y) {
        x = nxt[x][i];
        step += (1 << i);
      }
    }
    step += (x < y);
    printf("%d\n", step);
  }
  return 0;
}
