#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0, p = 1;
  char a = getchar();
  while ((a < 48 || a > 57) && a != '-') a = getchar();
  if (a == '-') p = -p, a = getchar();
  while (a > 47 && a < 58) {
    x = (x << 1) + (x << 3) + (a & 15);
    a = getchar();
  }
  return x * p;
}
inline void swap(long long &x, long long &y) {
  long long t = x;
  x = y;
  y = t;
}
const int N = 100002;
long long n, l, q, d[N], a[N];
namespace Treap {
long long val[N];
int size[N], son[N][2], rnd[N], Size, root, x, y, z;
inline void pushup(int rt) {
  size[rt] = size[son[rt][0]] + size[son[rt][1]] + 1;
}
inline void split(int rt, long long k, int &x, int &y) {
  if (!rt) {
    x = y = 0;
    return;
  } else if (val[rt] <= k)
    x = rt, split(son[rt][1], k, son[rt][1], y);
  else
    y = rt, split(son[rt][0], k, x, son[rt][0]);
  pushup(rt);
}
inline int merge(int a, int b) {
  if (!a || !b) return a + b;
  if (rnd[a] < rnd[b]) {
    son[a][1] = merge(son[a][1], b);
    pushup(a);
    return a;
  } else {
    son[b][0] = merge(a, son[b][0]);
    pushup(b);
    return b;
  }
}
inline int newnode(long long k) {
  size[++Size] = 1;
  val[Size] = k;
  rnd[Size] = rand();
  return Size;
}
inline void insert(long long k) {
  split(root, k, x, y);
  root = merge(merge(x, newnode(k)), y);
}
inline void del(long long k) {
  split(root, k, x, z);
  split(x, k - 1, x, y);
  y = merge(son[y][0], son[y][1]);
  root = merge(merge(x, y), z);
}
inline int rank(long long k) {
  split(root, k - 1, x, y);
  int ans = size[x] + 1;
  root = merge(x, y);
  return ans;
}
inline int kth(int rt, int k) {
  while (1) {
    if (k <= size[son[rt][0]])
      rt = son[rt][0];
    else if (k == size[son[rt][0]] + 1)
      return rt;
    else
      k -= size[son[rt][0]] + 1, rt = son[rt][1];
  }
  return -1;
}
inline int pre(long long k) {
  split(root, k, x, y);
  int ans = kth(x, size[x]);
  root = merge(x, y);
  return ans;
}
inline int suc(long long k) {
  split(root, k, x, y);
  int ans = kth(y, 1);
  root = merge(x, y);
  return ans;
}
}  // namespace Treap
using namespace Treap;
int main() {
  n = rd();
  for (int i = 1; i <= n; i++) a[i] = rd(), insert(a[i]);
  l = rd();
  q = rd();
  for (int i = 1; i < n; i++) d[i] = pre(a[i] + l);
  while (q--) {
    long long x, y, ans = 0;
    x = rd();
    y = rd();
    if (x > y) swap(x, y);
    while (x < y) x = d[x], ans++;
    printf("%lld\n", ans);
  }
  return 0;
}
