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()
  maxLeap := 30

  leapsRight := make([][]int, n)
  for i := range leapsRight {
    leapsRight[i] = make([]int, maxLeap + 1)
    for j := range leapsRight[i] {
      leapsRight[i][j] = -1
    }
  }
  left, right := 0, 1
  for right < n {
    for hotels[left] + hop < hotels[right] {
      leapsRight[left][0] = right - 1
      left++
    }
    right++
  }
  for left < n - 1 {
    leapsRight[left][0] = n - 1
    left++
  }
  for x := 0; x <= maxLeap; x++ {
    for a := 0; a < n; a++ {
      b := leapsRight[a][x]
      if b != -1 {
        c := leapsRight[b][x]
        if c != -1 {
          leapsRight[a][x + 1] = c
        }
      }
    }
  }

  leapsLeft := make([][]int, n)
  for i := range leapsLeft {
    leapsLeft[i] = make([]int, maxLeap + 1)
    for j := range leapsLeft[i] {
      leapsLeft[i][j] = -1
    }
  }
  left, right = n - 2, n - 1
  for left >= 0 {
    for hotels[right] - hop > hotels[left] {
      leapsLeft[right][0] = left + 1
      right--
    }
    left--
  }
  for right > 0 {
    leapsLeft[right][0] = 0
    right--
  }
  for x := 0; x <= maxLeap; x++ {
    for a := n - 1; a >= 0; a-- {
      b := leapsLeft[a][x]
      if b != -1 {
        c := leapsLeft[b][x]
        if c != -1 {
          leapsLeft[a][x + 1] = c
        }
      }
    }
  }

  numQueries := getI()
  for qi := 0; qi < numQueries; qi++ {
    a, b := getI() - 1, getI() - 1
    result := 0
    if a > b {
      a, b = b, a
    }
    if a < b {
      for x := maxLeap; x >= 0; x-- {
        for {
          p := leapsRight[a][x]
          if p == -1 || p > b {
            break
          }
          result += 1 << uint(x)
          a = p
          if a == b {
            break
          }
        }
      }
    } else {
      for x := maxLeap; x >= 0; x-- {
        p := leapsLeft[a][x]
        fmt.Printf("leapsLeft[%d][%d] = %d\n", a, x, p)
        if p != -1 && p >= b {
          result += 1 << uint(x)
          fmt.Printf("%d -> %d (%d)\n", a, p, 1 << uint(x))
          a = p
          if a == b {
            break
            fmt.Printf("done\n")
          }
        }
      }
    }
    writer.WriteString(fmt.Sprintf("%d\n", result))
  }
}
