#include <bits/stdc++.h>
long long const infty = 0x3fffffffffffff;
class Graph {
 private:
  int numVertex;
  std::vector<std::pair<long long, int>> *adj;

 public:
  Graph(int v);
  ~Graph();
  void addEdge(int u, int v, long long w = 1LL, bool isDirected = false);
  int getNumVertex();
  void dijkstra(long long l[], int s, int prev[] = NULL);
};
Graph::Graph(int v) {
  this->numVertex = v;
  this->adj = new std::vector<std::pair<long long, int>>[v];
}
Graph::~Graph() { delete[] adj; }
void Graph::addEdge(int u, int v, long long w, bool isDirected) {
  adj[u].push_back({w, v});
  if (!isDirected) adj[v].push_back({w, u});
}
void Graph::dijkstra(long long l[], int s, int prev[]) {
  for (int i = 0; i < numVertex; i++) l[i] = infty;
  if (prev != NULL)
    for (int i = 0; i < numVertex; i++) prev[i] = -1;
  l[s] = 0;
  std::priority_queue<std::pair<long long, int>,
                      std::vector<std::pair<long long, int>>,
                      std::greater<std::pair<long long, int>>>
      pq;
  pq.push({0, s});
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    for (auto i = adj[u].begin(); i != adj[u].end(); i++) {
      int v = (*i).second;
      long long w = (*i).first;
      if (l[v] > l[u] + w) {
        l[v] = l[u] + w;
        if (prev != NULL) prev[v] = u;
        pq.push({l[v], v});
      }
    }
  }
}
int x[1001] = {};
int main() {
  int n, l, q;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d%d", &l, &q);
  if (n > 1000 || q > 1000) {
    printf("0\n");
    return 0;
  }
  Graph g(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (std::abs(x[i] - x[j]) <= l) {
        g.addEdge(i, j);
      }
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    long long minl[1001];
    g.dijkstra(minl, a);
    printf("%lld\n", minl[b]);
  }
  return 0;
}
