package main

import (
  "fmt"
)

func query(H *[]int, dest, sign int) {
  if dest * sign <= (*H)[0] * sign {
    fmt.Println(1)
    return
  }
  l := 0
  h := len(*H) - 1
  var m int
  for ; h - l > 1; {
    m = (h + l) / 2
    if (*H)[m] * sign < dest * sign {
      l = m
    } else {
      h = m
    }
  }
  fmt.Println(h + 1)
}

func main() {
  var N, L, Q int
  fmt.Scan(&N)
  X := make([]int, N)
  for i := range X {
    fmt.Scan(&X[i])
  }
  fmt.Scan(&L)
  H := make([][]int, N)
  RH := make([][]int, N)
  for i := range H {
    H[i] = make([]int, 0)
    RH[i] = make([]int, 0)
  }
  s := 0
  t := 0
  length := 0
  for ; s < N - 1; {
    for ; length <= L; t++{
      if t == N - 1 {
        for ; s < N - 1; s++ {
          H[s] = append(H[s], N - 1)
        }
        break
      }
      length += X[t + 1] - X[t]
    }
    for ; length > L; s++ {
      H[s] = append(H[s], t - 1)
      length -= X[s + 1] - X[s]
    }
  }
  length = 0
  for ; s > 0; {
    for ; length <= L; t-- {
      if t == 0 {
        for ; s > 0; s-- {
          RH[s] = append(RH[s], 0)
        }
        break
      }
      length += X[t] - X[t - 1]
    }
    for ; length > L; s-- {
      RH[s] = append(RH[s], t + 1)
      length -= X[s] - X[s - 1]
    }
  }
  for i := 1; i < N; i++ {
    H[N - 1 - i] = append(H[N - 1 - i], H[H[N - 1 - i][0]]...)
    RH[i] = append(RH[i], RH[RH[i][0]]...)
  }
  fmt.Scan(&Q)
  var a, b int
  for i := 0; i < Q; i++ {
    fmt.Scan(&a, &b)
    if a < b {
      query(&H[a - 1], b - 1, 1)
    } else {
      query(&RH[a - 1], b - 1, -1)
    }
  }
}