#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int INF = 0x3f3f3f3f;
class endln {};
class iofstream {
 private:
  int idx;
  bool eof;
  char buf[100000], *ps, *pe;
  char bufout[100000], outtmp[50], *pout, *pend;
  inline void rnext() {
    if (++ps == pe)
      pe = (ps = buf) +
           fread(buf, sizeof(char), sizeof(buf) / sizeof(char), stdin),
      eof = true;
    if (ps == pe) eof = false;
  }
  inline void write() {
    fwrite(bufout, sizeof(char), pout - bufout, stdout);
    pout = bufout;
  }

 public:
  iofstream(char *in = NULL, char *out = NULL) : idx(-1), eof(true) {
    ps = buf, pe = buf + 1;
    pout = bufout, pend = bufout + 100000;
    if (in) freopen(in, "r", stdin);
    if (out) freopen(out, "w", stdout);
  }
  template <class T>
  inline bool fin(T &ans) {
    ans = 0;
    T f = 1;
    if (ps == pe) {
      eof = false;
      return false;
    }
    do {
      rnext();
      if ('-' == *ps) f = -1;
    } while (!isdigit(*ps) && ps != pe);
    if (ps == pe) {
      eof = false;
      return false;
    }
    do {
      ans = (ans << 1) + (ans << 3) + *ps - 48;
      rnext();
    } while (isdigit(*ps) && ps != pe);
    ans *= f;
    return true;
  }
  template <class T>
  inline bool fdb(T &ans) {
    ans = 0;
    T f = 1;
    if (ps == pe) return false;
    do {
      rnext();
      if ('-' == *ps) f = -1;
    } while (!isdigit(*ps) && ps != pe);
    if (ps == pe) return false;
    do {
      ans = ans * 10 + *ps - 48;
      rnext();
    } while (isdigit(*ps) && ps != pe);
    ans *= f;
    if (*ps == '.') {
      rnext();
      T small = 0;
      do {
        small = small * 10 + *ps - 48;
        rnext();
      } while (isdigit(*ps) && ps != pe);
      while (small >= 1) {
        small /= 10;
      }
      ans += small;
    }
    return true;
  }
  inline bool out_char(const char c) {
    *(pout++) = c;
    if (pout == pend) write();
    write();
    return true;
  }
  inline bool out_str(const char *s) {
    while (*s) {
      *(pout++) = *(s++);
      if (pout == pend) write();
    }
    write();
    return true;
  }
  template <class T>
  inline bool out_double(T x, int idx) {
    char str[50];
    string format = "%";
    if (~idx) {
      format += '.';
      format += (char)(idx + '0');
    }
    format += "f";
    sprintf(str, format.c_str(), x);
    out_str(str);
  }
  template <class T>
  inline bool out_int(T x) {
    if (!x) {
      out_char('0');
      return true;
    }
    if (x < 0) x = -x, out_char('-');
    int len = 0;
    while (x) {
      outtmp[len++] = x % 10 + 48;
      x /= 10;
    }
    outtmp[len] = 0;
    for (int i = 0, j = len - 1; i < j; i++, j--) swap(outtmp[i], outtmp[j]);
    out_str(outtmp);
    return true;
  }
  template <class T>
  inline bool out_intln(T x) {
    out_int(x), out_char('\n');
    write();
    return true;
  }
  template <class T>
  inline bool out_doubleln(T x, int idx) {
    out_double(x, idx), out_char('\n');
  }
  inline iofstream &operator<<(const double &x) {
    out_double(x, idx);
    return *this;
  }
  inline iofstream &operator<<(const int &x) {
    out_int(x);
    return *this;
  }
  inline iofstream &operator<<(const unsigned long long &x) {
    out_int(x);
    return *this;
  }
  inline iofstream &operator<<(const unsigned &x) {
    out_int(x);
    return *this;
  }
  inline iofstream &operator<<(const long &x) {
    out_int(x);
    return *this;
  }
  inline iofstream &operator<<(const long long &x) {
    out_int(x);
    return *this;
  }
  inline iofstream &operator<<(const endln &x) {
    out_char('\n');
    return *this;
  }
  inline iofstream &operator<<(const char *x) {
    out_str(x);
    return *this;
  }
  inline iofstream &operator<<(const string &x) {
    out_str(x.c_str());
    return *this;
  }
  inline iofstream &operator<<(const char &x) {
    out_char(x);
    return *this;
  }
  inline bool setw(int x) {
    if (x >= 0) {
      idx = x;
      return true;
    }
    return false;
  }
  inline iofstream &operator>>(int &x) {
    if (!fin(x)) eof = false;
    return *this;
  }
  inline iofstream &operator>>(long long &x) {
    if (!fin(x)) eof = false;
    return *this;
  }
  inline iofstream &operator>>(double &x) {
    if (!fdb(x)) eof = false;
    return *this;
  }
  inline iofstream &operator>>(float &x) {
    if (!fdb(x)) eof = false;
    return *this;
  }
  inline iofstream &operator>>(unsigned &x) {
    if (!fin(x)) eof = false;
    return *this;
  }
  inline iofstream &operator>>(unsigned long long &x) {
    if (!fin(x)) eof = false;
    return *this;
  }
  inline operator bool() { return eof; }
  inline char getchar() {
    if (ps == pe) {
      eof = false;
      return 0;
    }
    rnext();
    if (ps + 1 == pe) eof = false;
    return *ps;
  }
  inline iofstream &operator>>(char *str) {
    if (ps == pe) {
      eof = false;
      return *this;
    }
    do {
      rnext();
    } while (isspace(*ps) && iscntrl(*ps) && ps != pe);
    if (ps == pe) {
      eof = false;
      return *this;
    }
    do {
      *str = *ps;
      ++str;
      rnext();
    } while (!(isspace(*ps) || iscntrl(*ps)) && ps != pe);
    *str = '\0';
    return *this;
  }
  inline iofstream &operator>>(string &str) {
    str.clear();
    if (ps == pe) {
      eof = false;
      return *this;
    }
    do {
      rnext();
    } while (isspace(*ps) && iscntrl(*ps) && ps != pe);
    if (ps == pe) {
      eof = false;
      return *this;
    }
    do {
      str += *ps;
      rnext();
    } while (!(isspace(*ps) || iscntrl(*ps)) && ps != pe);
    return *this;
  }
  inline iofstream &getline(char *str) {
    if (ps == pe) {
      eof = false;
      return *this;
    }
    do {
      rnext();
      *str = *ps;
    } while (*ps != '\n' && ps != pe && str++);
    *str = '\0';
    return *this;
  }
  inline bool endfile() { return eof; }
};
static iofstream fin;
static endln ln;
class range {
 public:
  class iterator {
    friend class range;

   public:
    int operator*() const { return i_; }
    iterator &operator++() {
      ++i_;
      return *this;
    }
    iterator operator++(int) {
      iterator copy(*this);
      ++i_;
      return copy;
    }
    bool operator==(const iterator &other) const { return i_ == other.i_; }
    bool operator!=(const iterator &other) const { return i_ != other.i_; }

   protected:
    iterator(int start) : i_(start) {}

   private:
    int i_;
  };
  iterator begin() const { return begin_; }
  iterator end() const { return end_; }
  range(int begin, int end) : begin_(begin), end_(end) {}

 private:
  iterator begin_;
  iterator end_;
};
template <typename T>
class reverse_iterator_class {
 public:
  explicit reverse_iterator_class(const T &t) : t(t) {}
  typename T::const_reverse_iterator begin() const { return t.rbegin(); }
  typename T::const_reverse_iterator end() const { return t.rend(); }

 private:
  const T &t;
};
using long long = long long;
template <typename T>
reverse_iterator_class<T> reverse(const T &t) {
  return reverse_iterator_class<T>(t);
}
using LL = long long;
const LL mod = 1e9 + 7;
int x[100000];
int r[17][100000];
int main() {
  int n;
  fin >> n;
  for (auto i : range(0, n)) {
    fin >> x[i];
  }
  int l, q;
  fin >> l >> q;
  for (auto i : range(0, n)) {
    r[0][i] = upper_bound(x, x + n, x[i] + l) - x - 1;
  }
  for (int i = 1; i < 17; i++) {
    for (auto j : range(0, n)) {
      r[i][j] = r[i - 1][r[i - 1][j]];
    }
  }
  for (auto i : range(0, q)) {
    int a, b;
    fin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int cnt = 0;
    for (int i = 16; i >= 0; i--) {
      if (r[i][a] < b) {
        a = r[i][a];
        cnt += 1 << i;
      }
    }
    fin << cnt + 1 << ln;
  }
}
