#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1000000007;
const long long gosenchou = 5000000000000000;
short gh[2][4] = {{0, 0, -1, 1}, {-1, 1, 0, 0}};
struct P {
  long long pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
  long long to, cost;
};
struct E {
  long long from, to, cost;
};
bool operator<(E a, E b) { return a.cost < b.cost; }
struct H {
  long long x, y;
};
bool operator<(H a, H b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
bool operator>(H a, H b) {
  if (a.x != b.x) return a.x > b.x;
  return a.y > b.y;
}
bool operator==(H a, H b) { return a.x == b.x && a.y == b.y; }
bool operator!=(H a, H b) { return a.x != b.x || a.y != b.y; }
long long gcm(long long i, long long j) {
  if (i > j) swap(i, j);
  if (i == 0) return j;
  return gcm(j % i, i);
}
long double rad(H a, H b) {
  return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}
long long ari(long long a, long long b, long long c) { return (a + b) * c / 2; }
long long fact(long long x, long long k, long long p) {
  long long sum = 1;
  for (int i = 0; i < k; i++) {
    sum *= (x--);
    sum %= p;
  }
  return sum;
}
long long mod_pow(long long x, long long n, long long p) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % p;
    x = x * x % p;
    n >>= 1;
  }
  return res;
}
int ctoi(char a) { return (int)a - '0'; }
const long long Inf = 4523372036854775807;
const long long inf = 15000000000;
long long n, l, q;
long long a[100000];
long long c[100000][40];
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  cin >> l >> q;
  for (long long i = 0; i < 100000; i++) {
    for (long long j = 0; j < 40; j++) c[i][j] = -1;
  }
  for (long long i = 0; i < n - 1; i++) {
    long long k = upper_bound(a, a + n, a[i] + l) - a;
    c[i][0] = k - 1;
  }
  for (long long j = 1; j < 40; j++) {
    for (long long i = 0; i < n; i++) {
      if (c[i][j - 1] == -1 || c[c[i][j - 1]][j - 1] == -1) {
        c[i][j] = -1;
      } else {
        c[i][j] = c[c[i][j - 1]][j - 1];
      }
    }
  }
  for (long long i = 0; i < q; i++) {
    long long x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    x--;
    y--;
    long long ans = 0;
    for (long long i = 39; i >= 0; i--) {
      if (c[x][i] > y || c[x][i] == -1) continue;
      ans += 1 << i;
      x = c[x][i];
    }
    cout << ans << endl;
  }
  getchar();
  getchar();
}
