#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T>& operator<<(vector<T>& v, const T t) {
  v.push_back(t);
  return v;
}
template <typename T>
multiset<T>& operator<<(multiset<T>& m, const T t) {
  m.insert(t);
  return m;
}
template <typename T>
set<T>& operator<<(set<T>& s, const T t) {
  s.insert(t);
  return s;
}
template <typename T, typename U>
priority_queue<T, vector<T>, U>& operator<<(priority_queue<T, vector<T>, U>& q,
                                            const T t) {
  q.push(t);
  return q;
}
template <typename T, typename U>
istream& operator>>(istream& s, pair<T, U>& p) {
  return s >> p.first >> p.second;
}
template <typename T>
istream& operator>>(istream& s, vector<T>& v) {
  for (int i = 0; i < (v.size()); ++i) {
    s >> v[i];
  }
  return s;
}
template <typename T, typename U>
ostream& operator<<(ostream& s, const pair<T, U> p) {
  return s << p.first << " " << p.second;
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T> v) {
  for (auto a : v) {
    s << a << endl;
  }
  return s;
}
template <typename T, typename U>
pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {
  return {a.first + b.first, a.second + b.second};
}
template <typename T, typename U>
pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {
  return {a.first - b.first, a.second - b.second};
}
template <typename T>
void print(T x) {
  cout << x << endl;
}
template <typename T, typename U>
void print(T x, U y) {
  cout << x << " " << y << endl;
}
template <typename T, typename U, typename V>
void print(T x, U y, V z) {
  cout << x << " " << y << " " << z << endl;
}
const int MD = 1e9 + 7;
template <typename T>
string to_string(const T& n) {
  ostringstream s;
  s << n;
  return s.string();
}
template <typename T, typename U>
vector<pair<T, U>> dijkstra(const vector<vector<pair<T, U>>> E, const U s,
                            const T inf) {
  using P = pair<T, U>;
  vector<P> d;
  for (int i = 0; i < (E.size()); ++i) {
    d << P{inf, i};
  }
  priority_queue<P, vector<P>, greater<P>> pq;
  pq << (d[s] = P{0, s});
  while (pq.size()) {
    P a = pq.top();
    pq.pop();
    U v = a.second;
    if (d[v].first >= a.first) {
      for (P e : E[v]) {
        if (d[v].first + e.first < d[e.second].first) {
          d[e.second] = P{d[v].first + e.first, v};
          pq << P{d[v].first + e.first, e.second};
        }
      }
    }
  }
  return d;
}
template <typename T, typename U>
map<U, pair<T, U>> dijkstra(map<U, vector<pair<T, U>>> E, const U s,
                            const T inf) {
  using P = pair<T, U>;
  map<U, P> d;
  for (pair<U, vector<P>> e : E) {
    d[e.first] = P{inf, e.first};
  }
  priority_queue<P, vector<P>, greater<P>> pq;
  pq << (d[s] = P{0, s});
  while (pq.size()) {
    P a = pq.top();
    pq.pop();
    U v = a.second;
    if (d[v].first >= a.first) {
      for (P e : E[v]) {
        if (d[v].first + e.first < d[e.second].first) {
          d[e.second] = P{d[v].first + e.first, v};
          pq << P{d[v].first + e.first, e.second};
        }
      }
    }
  }
  return d;
}
template <typename T>
T distsq(pair<T, T> a, pair<T, T> b) {
  return (a.first - b.first) * (a.first - b.first) +
         (a.second - b.second) * (a.second - b.second);
}
template <typename T>
T max(const vector<T> a) {
  T m = a[0];
  for (T e : a) {
    m = max(m, e);
  }
  return m;
}
template <typename T>
T min(const vector<T> a) {
  T m = a[0];
  for (T e : a) {
    m = min(m, e);
  }
  return m;
}
template <typename T>
T gcd(const T a, const T b) {
  return a ? gcd(b % a, a) : b;
}
template <typename T>
T gcd(const vector<T> a) {
  T g = a[0];
  for (T e : a) {
    g = gcd(g, e);
  }
  return g;
}
template <typename T>
vector<T> LIS(const vector<T> A) {
  vector<int> B;
  for (T a : A) {
    auto it = lower_bound(B.begin(), B.end(), a);
    if (it == B.end()) {
      B << a;
    } else {
      *it = a;
    }
  }
  return B;
}
long long strmod(const string& s, const int m) {
  long long x = 0;
  for (int i = 0; i < (s.size()); ++i) {
    x = (x * 10 + s[i] - 48) % m;
  }
  return x;
}
vector<vector<long long>> mul(const vector<vector<long long>>& A,
                              const vector<vector<long long>>& B, const int m) {
  vector<vector<long long>> C;
  for (int y = 0; y < (A.size()); ++y) {
    C << vector<long long>(B[y].size());
  }
  for (int y = 0; y < (C.size()); ++y) {
    for (int x = 0; x < (C[y].size()); ++x) {
      for (int i = 0; i < (A[0].size()); ++i) {
        (C[y][x] += A[y][i] * B[i][x]) %= m;
      }
    }
  }
  return C;
}
vector<vector<long long>> pow(const vector<vector<long long>>& A,
                              const long long n, const int m) {
  vector<vector<long long>> B;
  for (int y = 0; y < (A.size()); ++y) {
    B << vector<long long>(A.size());
  }
  if (n == 0) {
    for (int i = 0; i < (B.size()); ++i) {
      B[i][i] = 1;
    }
  } else if (n % 2) {
    B = mul(A, pow(A, n - 1, m), m);
  } else {
    vector<vector<long long>> C = pow(A, n / 2, m);
    B = mul(C, C, m);
  }
  return B;
}
long long pow(const long long a, const long long n, const int m) {
  long long t;
  return n ? (n & 1 ? a >= 0 ? a % m : ~-m + ~a % m : 1) *
                 (t = pow(a, n >> 1, m), t * t % m) % m
           : !!a;
}
long long inv(const long long x, const int p) { return pow(x, p - 2, p); }
vector<pair<long long, long long>> fact(const int n, const int p) {
  vector<pair<long long, long long>> v(n + 1);
  v[0].first = 1;
  for (int i = (1); i <= (n); ++i) {
    v[i].first = v[i - 1].first * i % p;
  }
  v[n].second = inv(v[n].first, p);
  for (int i = (n); i >= (1); --i) {
    v[i - 1].second = v[i].second * i % p;
  }
  return v;
}
long long C2(const int n) { return (long long)n * ~-n / 2; }
long long sum(const vector<int> a) {
  long long s = 0;
  for (int e : a) {
    s += e;
  }
  return s;
}
long long sum(const vector<long long> a) {
  long long s = 0;
  for (long long e : a) {
    s += e;
  }
  return s;
}
long long segsum(vector<long long>& s, int l, int r) {
  l |= s.size() >> 1;
  r |= s.size() >> 1;
  if (l > r) {
    return 0;
  }
  if (l == r) {
    return s[l];
  }
  long long z = s[l] + s[r];
  for (; l >> 1 < r >> 1; l >>= 1, r >>= 1) {
    l & 1 || (z += s[l ^ 1]);
    r & 1 && (z += s[r ^ 1]);
  }
  return z;
}
void segadd(vector<long long>& s, int i, long long x) {
  s[i |= s.size() >> 1] += x;
  for (; i >> 1 >= 1; i >>= 1) {
    s[i >> 1] = s[i] + s[i ^ 1];
  }
}
long long BITsum(vector<long long>& B, int i) {
  long long z = 0;
  while (i > 0) {
    z += B[i];
    i -= i & -i;
  }
  return z;
}
void BITadd(vector<long long>& B, int i, long long x) {
  while (i < B.size()) {
    B[i] += x;
    i += i & -i;
  }
}
long long fib(const long long n, const int m) {
  long long a, b, c, d, A, B, C, D;
  a = 1;
  b = 0;
  c = 0;
  d = 1;
  for (int i = (63); i--;) {
    A = a * a + b * c;
    B = a * b + b * d;
    C = c * a + d * c;
    D = c * b + d * d;
    if (n >> i & 1) {
      a = A;
      b = B;
      c = C;
      d = D;
      A = a + b;
      B = a;
      C = c + d;
      D = c;
    }
    a = A % m;
    b = B % m;
    c = C % m;
    d = D % m;
  }
  return b;
}
vector<int> primes(int n) {
  vector<bool> b(n + 1);
  vector<int> p;
  for (int i = (2); i <= (n); ++i) {
    if (!b[i]) {
      p << i;
      for (int j = 2 * i; j <= n; j += i) {
        b[j] = true;
      }
    }
  }
  return p;
}
int LR[100000][30];
int RL[100000][30];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, L, Q;
  cin >> N;
  vector<int> x(N);
  cin >> x >> L >> Q;
  {
    int j = 0;
    for (int i = 0; i < (N); ++i) {
      while (j + 1 < N && x[j + 1] <= x[i] + L) ++j;
      LR[i][0] = j;
    }
    for (int k = (1); k <= (29); ++k) {
      for (int i = 0; i < (N); ++i) {
        LR[i][k] = LR[LR[i][k - 1]][k - 1];
      }
    }
    j = N - 1;
    for (int i = (N); i--;) {
      while (j - 1 >= 0 && x[j - 1] >= x[i] - L) --j;
      RL[i][0] = j;
    }
    for (int k = (1); k <= (29); ++k) {
      for (int i = (N); i--;) {
        RL[i][k] = RL[RL[i][k - 1]][k - 1];
      }
    }
  }
  for (int i = 0; i < (Q); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    int z = 0, k = 29;
    if (a < b) {
      do {
        while (k > 0 && b < LR[a][k]) --k;
        z += 1 << k;
        a = LR[a][k];
      } while (a < b);
    } else {
      do {
        while (k > 0 && b > RL[a][k]) --k;
        z += 1 << k;
        a = RL[a][k];
      } while (a > b);
    }
    print(z);
  }
  return 0;
}
