#include <bits/stdc++.h>
using namespace std;
long long x[100010];
long long jump[100010][25];
long long cost[100010][25];
map<long long, long long> mp;
long long Find(long long a, long long b) {
  long long i, j, k, l;
  long long ans = 0;
  k = a;
  for (i = 25; i >= 0; i--) {
    l = jump[k][i];
    if (l > b) continue;
    ans += cost[k][i];
    k = l;
  }
  if (k < b && x[k] != x[b]) ans++;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long i, j, k, l;
  long long n, m, L, a, b;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x[i];
  }
  cin >> L;
  x[n + 1] = 10000000000;
  j = 1;
  for (i = 1; i <= n; i++) {
    while (x[j] - x[i] <= L) j++;
    jump[i][0] = j - 1;
    cost[i][0] = 1;
  }
  jump[n][0] = n + 1;
  cost[n][0] = x[n + 1];
  jump[n + 1][0] = n + 1;
  cost[n + 1][0] = x[n + 1];
  int WA = 1;
  for (j = 1; j <= 25; j++) {
    for (i = 1; i <= n + WA; i++) {
      jump[i][j] = jump[jump[i][j - 1]][j - 1];
      cost[i][j] = cost[i][j - 1] * 2;
    }
  }
  long long q;
  cin >> q;
  while (q--) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    cout << Find(a, b) << '\n';
  }
}
