package main

import (
  "bufio"
  "container/heap"
  "fmt"
  "os"
  "sort"
  "strconv"
  "strings"
)

const INF int = 100000000

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,1000000)}
  n := input.NextInt()
  x := append(append([]int{0},input.NextIntArray()...),2100000000)
  l := input.NextInt()
  q := input.NextInt()
  g := NewGraph(n+1)
  for i:=1;i<n+1;i++ {
    j := sort.Search(n+2,func(j int) bool { return x[i]+l < x[j] })
    for k:=i+1;k<j;k++ { g.Add(i,k,1) }
  }
  for k:=0;k<q;k++ {
    a,b := input.NextInts()
    if a > b { a,b = b,a }
    c := g.Dijkstra(a)
    fmt.Println(c[b])
  }
}

type Item struct { pos,cost,idx int }
type PriorityQueue []*Item
func(pq PriorityQueue) Len() int { return len(pq) }
func(pq PriorityQueue) Less(i,j int) bool { return pq[i].cost < pq[j].cost }
func(pq PriorityQueue) Swap(i,j int) {
  pq[i],pq[j] = pq[j],pq[i]
  pq[i].idx,pq[j].idx = i,j
}
func(pq *PriorityQueue) Push(x interface{}) {
  n := len(*pq)
  item := x.(*Item)
  item.idx = n
  *pq = append(*pq,item)
}
func(pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n-1]
  item.idx = -1
  *pq = old[0:n-1]
  return item
}

type Edge struct { to,cost int }
type Graph [][]Edge
func NewGraph(n int) Graph { return make([][]Edge,n) }
func(g Graph) AddEdge(from int,e Edge) { g[from] = append(g[from],e) }
func(g Graph) Add(from,to,cost int) { g.AddEdge(from,Edge{to,cost}) }
func(g Graph) Dijkstra(start int) []int {
  n := len(g)
  c := make([]int,n)
  for i:=0;i<n;i++ { c[i] = INF }
  var pq PriorityQueue
  heap.Init(&pq)
  heap.Push(&pq,&Item{pos:start,cost:0})
  c[start] = 0
  for pq.Len() > 0 {
    s := heap.Pop(&pq).(*Item)
    if s.cost > c[s.pos] { continue }
    for _, e := range g[s.pos] {
      if c[e.to] > s.cost+e.cost {
        c[e.to] = s.cost+e.cost
        heap.Push(&pq,&Item{pos:e.to,cost:c[e.to]})
      }
    }
  }
  return c
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) NextInts() (int,int) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}
func(i *Input) NextIntArray() []int {
  s := strings.Split(i.NextLine()," ")
  a := make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}