package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  hotels := make([]int, n)
  for i := range hotels {
    hotels[i] = getI()
  }
  hop := getI()
  leaps := make([][]int, n)
  maxLeap := 30
  for i := range leaps { 
    leaps[i] = make([]int, maxLeap + 1)
    for j := range leaps[i] { 
      leaps[i][j] = -1
    }
  }
  left, right := 0, 1
  for right < n {
    for hotels[left] + hop < hotels[right] {
      leaps[left][0] = right - 1 
      left++
    }
    right++
  }
  for left < n - 1 {
    leaps[left][0] = n - 1 
    left++
  }
  for x := 0; x <= maxLeap; x++ {
    for a := 0; a < n; a++ {
      b := leaps[a][x]
      if b != -1 {
        c := leaps[b][x]
        if c != -1 {
          leaps[a][x + 1] = c
        }
      }
    }
  }
  
  numQueries := getI()
  for qi := 0; qi < numQueries; qi++ {
    a, b := getI() - 1, getI() - 1
    if a > b {
      a, b = b, a
    }
    result := 0
    for x := maxLeap; x >= 0; x-- {
      p := leaps[a][x]
      if p != -1 && p <= b {
        result += 1 << uint(x)
        a = p
        if a == b {
          break
        }
      }
    }
    writer.WriteString(fmt.Sprintf("%d\n", result))
  }
}