#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-10;
const long long INFLL = (long long)(1e9) * (long long)(1e9);
const int INF = 1e9 + 7;
template <class T>
void chmin(T& a, const T b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T b) {
  if (a < b) a = b;
}
const long long powLL(const long long p, const long long q) {
  long long t = 1;
  for (int i = 0; i < q; i++) t *= p;
  return t;
}
template <typename T>
struct has_iter {
 private:
  template <typename U>
  static constexpr true_type check(typename U::iterator*);
  template <typename U>
  static constexpr false_type check(...);

 public:
  static constexpr bool value = decltype(check<T>(nullptr))::value;
};
template <typename T, typename U = typename T::iterator>
void print(const T& container) {
  auto &&first = begin(container), last = end(container);
  auto&& back = prev(last);
  for (auto e = first; e != last; e = next(e)) cout << *e << " \n"[e == back];
}
extern void* enabler;
template <typename Head,
          typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head) {
  cout << head << "\n";
}
template <>
void print<string>(const string& container) {
  cout << container << "\n";
}
template <typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail) {
  cout << head << " ";
  print(tail...);
}
void io_speedup() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
}
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << '(' << p.first << ", " << p.second << ')';
  return os;
}
template <typename T>
vector<T> read(int n) {
  vector<T> t(n);
  cin >> t;
  return t;
}
template <typename T>
T read() {
  T t;
  cin >> t;
  return t;
}
template <typename Head, typename... Tail>
struct vector_demensions {
  using type = vector<typename vector_demensions<Tail...>::type>;
};
template <typename Head>
struct vector_demensions<Head> {
  using type = Head;
};
template <typename T>
vector<T> make_vectors(int size, T val) {
  return vector<T>(size, val);
}
template <typename T = int, typename... Args>
auto make_vectors(int size, Args... tail) ->
    typename vector_demensions<Args..., T>::type {
  auto val = make_vectors<T>(forward<Args>(tail)...);
  return vector<decltype(val)>(size, val);
}
class Mod {
 public:
  using value_type = long long;

 private:
  static const value_type MODULO = 1e9 + 7;
  value_type value;
  constexpr value_type Normalize(value_type x) const {
    return x < 0 ? (x % MODULO + MODULO) : (x % MODULO);
  }

 public:
  constexpr Mod() : value(0) {}
  constexpr Mod(const value_type& val) : value(Normalize(val)) {}
  explicit operator value_type() const { return value; }
  constexpr const Mod operator-() const { return Mod(MODULO - value); }
  constexpr const Mod operator+(const Mod& rhs) const {
    return Mod(value + rhs.value);
  }
  constexpr const Mod operator-(const Mod& rhs) const {
    return Mod(value + (-rhs).value);
  }
  constexpr const Mod operator*(const Mod& rhs) const {
    return Mod(value * rhs.value);
  }
  Mod& operator+=(const Mod& rhs) { return *this = *this + rhs; }
  Mod& operator-=(const Mod& rhs) { return *this = *this - rhs; }
  Mod& operator*=(const Mod& rhs) { return *this = *this * rhs; }
  Mod pow(value_type p) const;
  Mod inv() const { return pow(MODULO - 2); }
  const Mod operator/(const Mod& rhs) const { return *this * rhs.inv(); }
  Mod& operator/=(const Mod& rhs) { return *this = *this / rhs; }
  constexpr bool operator==(const Mod& rhs) { return value == rhs.value; }
};
Mod Mod::pow(value_type p) const {
  Mod tmp = 1, mult = *this;
  while (p) {
    if ((p & 1) > 0) tmp *= mult;
    p >>= 1;
    mult *= mult;
  }
  return tmp;
}
namespace std {
ostream& operator<<(ostream& os, const Mod mod) {
  os << (typename Mod::value_type)mod;
  return os;
}
};  // namespace std
class Factorial {
 private:
  vector<Mod> ary;

 public:
  explicit Factorial(const size_t size) : ary(vector<Mod>(size)) {
    ary[0] = 1;
    for (size_t i = 1; i < size; i++) ary[i] = ary[i - 1] * i;
  }
  size_t size() const { return ary.size(); }
  Mod operator[](const int id) const { return ary[id]; }
};
class FactorialInv {
 private:
  vector<Mod> ary;

 public:
  explicit FactorialInv(const Factorial& fact) : ary(vector<Mod>(fact.size())) {
    for (size_t i = 0; i < ary.size(); i++) ary[i] = fact[i].inv();
  }
  Mod operator[](const int id) const { return ary[id]; }
};
class Combination {
 private:
  const Factorial* fact;
  const FactorialInv* fact_inv;

 public:
  Combination(const Factorial& fact_, const FactorialInv& fact_inv_)
      : fact(&fact_), fact_inv(&fact_inv_) {}
  Mod operator()(const int n, const int m) const {
    return (*fact)[n] * (*fact_inv)[m] * (*fact_inv)[n - m];
  }
};
int main() {
  int n;
  cin >> n;
  auto x(read<int>(n));
  const int N = 20;
  vector<vector<int>> p(n, vector<int>(N));
  int l, q;
  cin >> l >> q;
  int d = 1;
  for (int i = (0); i < (int)(n); ++i) {
    while (d < n && x[d] - x[i] <= l) d++;
    p[i][0] = d - 1;
  }
  for (int j = (0); j < (int)(N - 1); ++j)
    for (int i = (0); i < (int)(n); ++i) {
      p[i][j + 1] = p[p[i][j]][j];
    }
  for (int tt = (0); tt < (int)(q); ++tt) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    long long cnt = 0;
    while (a < b) {
      auto ptr = lower_bound(p[a].begin(), p[a].end(), b);
      int k;
      if (*ptr == b) {
        k = ptr - p[a].begin();
      } else if (ptr != p[a].begin()) {
        --ptr;
        k = ptr - p[a].begin();
      } else {
        k = 0;
      }
      cnt += powLL(2, k);
      if (k == 0 && b <= *ptr)
        a = b;
      else
        a = p[a][k];
    }
    print(cnt);
  }
}
