#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];
set<int> last;
int L, n, Q;
int x[100000 + 5], far[100000 + 5];
int dp[100000 + 5];
int ans[100000 + 5];
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;
}
bool cmp(node a, node b) { return a.to < b.to; }
void prepare() {
  for (int i = 1; i <= n; i++) {
    int val = x[i] + L;
    int pos = Lower_bound(val);
    far[i] = pos;
  }
}
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;
  for (int i = 1; i <= Q; i++) {
    scanf("%d %d", &x, &y);
    if (x > y) swap(x, y);
    q[x].push_back(node(y, i));
  }
  for (int i = 1; i <= n; i++) {
    if (q[i].size() == 0) continue;
    if (dp[i] != 0)
      for (int j = 0; j < q[i].size(); j++)
        ans[q[i][j].id] = dp[*last.lower_bound(q[i][j].to)] - dp[i];
    else {
      last.clear();
      int pos = i, lastpos = i;
      dp[i] = 0;
      last.insert(i);
      while (pos < n) {
        lastpos = pos;
        pos = far[pos];
        last.insert(pos);
        dp[pos] = dp[lastpos] + 1;
      }
      for (int j = 0; j < q[i].size(); j++)
        ans[q[i][j].id] = dp[*last.lower_bound(q[i][j].to)] - dp[i];
    }
  }
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
  return 0;
}
