#include <bits/stdc++.h>
using namespace std;
vector<int> furthest_left, furthest_right;
int ans;
void left(int a, int b) {
  ans += 1;
  int next_a = furthest_left[a];
  if (next_a > b)
    left(next_a, b);
  else
    return;
}
void right(int a, int b) {
  ans += 1;
  int next_a = furthest_right[a];
  if (next_a < b)
    right(next_a, b);
  else
    return;
}
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  int l, q;
  cin >> l >> q;
  vector<int> a(q), b(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
    a[i] -= 1;
    b[i] -= 1;
  }
  furthest_left.resize(n);
  furthest_right.resize(n);
  for (int i = 0; i < n; i++) {
    furthest_left[i] = lower_bound(x.begin(), x.end(), x[i] - l) - x.begin();
    furthest_right[i] =
        upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
  }
  for (int i = 0; i < q; i++) {
    ans = 0;
    if (a[i] > b[i]) left(a[i], b[i]);
    if (a[i] < b[i]) right(a[i], b[i]);
    cout << ans << endl;
  }
  return 0;
}
