#include <bits/stdc++.h>
using namespace std;
int n, l, q, x[100000];
int a[100000], b[100000];
int dist[2][100000], node[2][100000];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  cin >> l >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
  }
  node[0][0] = 0;
  int i = 0;
  while (true) {
    int s = i;
    for (i = s + 1; i < n && x[i] - x[s] <= l; i++) {
      dist[0][i] = dist[0][s] + 1;
      node[0][i] = s;
    }
    if (i == n) break;
    i--;
  }
  node[1][n - 1] = 0;
  i = n - 1;
  while (true) {
    int s = i;
    for (i = s - 1; i >= 0 && x[s] - x[i] <= l; i--) {
      dist[1][i] = dist[1][s] + 1;
      node[1][i] = s;
    }
    i++;
    if (i == 0) break;
  }
  for (int i = 0; i < q; i++) {
    int ans = 0, index;
    if (a[i] <= b[i])
      index = 0;
    else
      index = 1;
    if (node[index][a[i] - 1] != node[index][b[i] - 1]) {
      if ((!index && node[index][a[i] - 1] != node[index][a[i]]) ||
          (index && node[index][a[i] - 1] != node[index][a[i] - 2])) {
        ans = dist[index][node[index][b[i] - 1]] - dist[index][a[i] - 1] + 1;
      } else {
        ans = dist[index][node[index][b[i] - 1]] -
              dist[index][node[index][a[i] - 1]] + 1;
      }
    } else {
      ans = 1;
    }
    cout << ans << endl;
  }
}
