#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 7;
const long long MOD = 1000000007;
class Hotel {
 public:
  long long dist;
  long long no;
  vector<long long> d;
};
long long mypow(long long n, long long x) {
  long long res = 1;
  long long cur = n;
  while (x > 0) {
    if (x & 1) res *= cur;
    cur *= cur;
    x /= 2;
  }
  return res;
}
signed main() {
  long long n;
  cin >> n;
  vector<long long> x(n);
  for (long long i = 0; i < n; ++i) cin >> x[i];
  x.push_back(inf);
  vector<Hotel> h(n + 1);
  long long l, q;
  cin >> l;
  cin >> q;
  for (long long i = 0; i < 100; ++i) {
    h[n].d.push_back(n);
  }
  for (long long i = 0; i < n; ++i) {
    h[i].no = i;
    h[i].dist = x[i];
    auto it = upper_bound(x.begin(), x.end(), x[i] + l);
    --it;
    long long ind = it - x.begin();
    h[i].d.push_back(ind);
  }
  for (long long k = 1; k <= 50; ++k) {
    for (long long i = 0; i < n; ++i) {
      h[i].d.push_back(h[h[i].d[k - 1]].d[k - 1]);
    }
  }
  vector<long long> res(q);
  for (long long i = 0; i < q; ++i) {
    long long a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) {
      swap(a, b);
    }
    long long buf = 0;
    long long cur = a;
    while (cur != b) {
      if (b < h[cur].d[0]) {
        buf += 1;
        break;
      }
      auto it = upper_bound(h[cur].d.begin(), h[cur].d.end(), b);
      --it;
      long long ind = it - h[cur].d.begin();
      cur = *it;
      buf += mypow(2, ind);
    }
    res[i] = buf;
  }
  for (const auto& val : res) {
    cout << val << "\n";
  }
  for (auto& val : h[1].d) {
  }
  return 0;
}
