#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007LL;
int n, l, q;
int x[100005];
int cnt;
int idx[100005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x[i]);
  }
  scanf("%d", &l);
  cnt = 1;
  long long sum = 0;
  idx[0] = 1;
  for (int i = 2; i <= n; ++i) {
    if (sum + x[i] - x[i - 1] > l) {
      idx[cnt++] = i - 1;
      sum = x[i] - x[i - 1];
    } else {
      sum += x[i] - x[i - 1];
    }
  }
  if (sum) {
    idx[cnt] = n;
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    int y = 0, z = cnt;
    int id1, id2;
    while (y < z) {
      int mid = (y + z) / 2;
      if (idx[mid] < b) {
        y = mid + 1;
      } else {
        z = mid;
      }
    }
    id2 = y;
    y = 0, z = cnt;
    while (y < z) {
      int mid = (y + z + 1) / 2;
      if (idx[mid] > a) {
        z = mid - 1;
      } else {
        y = mid;
      }
    }
    id1 = y;
    cout << id2 - id1 << endl;
  }
  return 0;
}
