#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> xs(n);
  for (auto &x : xs) scanf("%d", &x);
  int l, q;
  scanf("%d%d", &l, &q);
  vector<pair<int, int>> qs(q);
  for (auto &q : qs) scanf("%d%d", &q.first, &q.second), q.first--, q.second--;
  vector<vector<int>> skip(20, vector<int>(n));
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < n; j++) {
      if (i == 0) {
        if (j == n - 1)
          skip[i][j] = n;
        else
          skip[i][j] =
              prev(upper_bound(xs.begin(), xs.end(), xs[j] + l)) - xs.begin();
      } else {
        skip[i][j] = skip[i - 1][j];
        if (skip[i][j] < n) skip[i][j] = skip[i - 1][skip[i][j]];
      }
    }
  }
  for (auto &q : qs) {
    int ans = 0, cur = q.first, goal = q.second;
    if (cur > goal) swap(cur, goal);
    while (cur < goal) {
      int longest = 0, next = cur;
      for (int i = 0; i < 20; i++) {
        if (skip[i][cur] > goal)
          break;
        else {
          longest = 1 << i;
          next = skip[i][cur];
        }
      }
      cur = next;
      ans += longest;
    }
    cout << ans << endl;
  }
  return 0;
}
