#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int N = 2e5 + 5;
int n, l, q, x[N], a, b;
vector<int> all;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", x + i);
    all.push_back(x[i]);
  }
  sort(all.begin(), all.end());
  scanf("%d", &l);
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &a, &b);
    a = x[a];
    b = x[b];
    if (a > b) swap(a, b);
    int t = 0;
    while (a != b) {
      int to = min(b, a + l);
      int st = 0, en = all.size() - 1;
      while (st < en) {
        int mid = (st + en + 1) / 2;
        if (all[mid] < a)
          st = mid + 1;
        else if (all[mid] - a > l)
          en = mid - 1;
        else
          st = mid;
      }
      a = all[st];
      ++t;
    }
    printf("%d\n", t);
  }
  return 0;
}
