package main

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

func scanInt(scanner *bufio.Scanner) (i int) {
	if scanner.Scan() {
		bs := scanner.Bytes()
		for _, b := range bs {
			i = i*10 + int(b-'0')
		}
	}
	return
}

func minDayCountImpl(l, a, b int, x []int, dp map[int]map[int]int) int {
	if x[b] - x[a] <= l {
		return 1
	}
	if minDayCount, ok := dp[a][b]; ok {
		return minDayCount
	}
	isSet := false
	minDayCount := 0
	for c := a + 1; c < b; c++ {
		dayCount0 := minDayCountImpl(l, a, c, x, dp)
		dayCount1 := minDayCountImpl(l, c, b, x, dp)
		dayCount := dayCount0 + dayCount1
		if !isSet || dayCount < minDayCount {
			minDayCount = dayCount
			if dpa, ok := dp[a]; ok {
				dpa[b] = minDayCount
			} else {
				dp[a] = map[int]int{b: minDayCount}
			}
			isSet = true
		}
	}
	return minDayCount
}

func minDayCount(l, a, b int, x []int) int {
	dp := make(map[int]map[int]int)
	if a > b {
		a, b = b, a
	}
	return minDayCountImpl(l, a-1, b-1, x, dp)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	n := scanInt(scanner) // 2 <= n <= 10,000
	x := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = scanInt(scanner) // 1 <= x[0] < x[1] < ... < x[n-1] <= 100,000,000
	}
	l := scanInt(scanner) // 1 <= l <= 100,000,000, x[i+1] - x[i] <= l
	q := scanInt(scanner) // 1 <= q <= 10,000
	for j := 0; j < q; j++ {
		a := scanInt(scanner) // 1 <= a <= n, a != b
		b := scanInt(scanner) // 1 <= b <= n, a != b
		fmt.Println(minDayCount(l, a, b, x))
	}
}
