#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, L, q, x[N], sp[N][20];
int get(int x, int y) {
  int ans = 0, cur = 18;
  while (sp[x][cur] == -1) cur--;
  while (x < y) {
    if (sp[x][cur] <= y) {
      x = sp[x][cur];
      ans += (1 << cur);
    }
    cur--;
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> L >> q;
  memset(sp, -1, sizeof(sp));
  for (int i = 0; i < n; i++) {
    sp[i][0] = upper_bound(x, x + n, x[i] + L) - x - 1;
  }
  for (int j = 1; j < 18; j++)
    for (int i = 0; i < n; i++)
      if (sp[i][j - 1] != -1) sp[i][j] = sp[sp[i][j - 1]][j - 1];
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    cout << get(a - 1, b - 1) << "\n";
  }
  return 0;
}
