package main

import (
    "fmt"
)

func main() {
    var n int 
    fmt.Scan(&n)
    xs := make([]int, n+1)
    for i := 0; i < n; i++ {
        fmt.Scan(&xs[i])
    }   
    xs[n] = 1e12

    var l, cnt int 
    fmt.Scan(&l)
    m := make(map[int]int)
    ds := make([][]int, 0)
    for i := 0; i < n; i++ {
        if _, ok := m[i]; ok {
            continue
        }   
        m[i] = cnt 
        lx := xs[i]
        ds = append(ds, make([]int, i+1))
        ds[cnt][i] = 0 
        d := 1
        for j := i + 1; j < n; j++ {
            ds[cnt] = append(ds[cnt], d)
            if xs[j+1]-lx > l { 
                if _, ok := m[j]; ok {
                    break
                }   
                m[j] = cnt 
                lx = xs[j]
                d++ 
            }   
        }   
        cnt++
    }   

    var q int 
    fmt.Scan(&q)
    for i := 0; i < q; i++ {
        var a, b int 
        fmt.Scan(&a, &b) 
        a-- 
        b-- 
        if b < a { 
            a, b = b, a
        }   
        var sum int 
        for {
            if v, ok := m[a]; ok {
                if len(ds[v]) > b { 
                    sum += ds[v][b] - ds[v][a]
                    break
                } else {
                    sum += ds[v][len(ds[v])-1] - ds[v][a]
                    a = len(ds[v]) - 1 
                }   
            } else {
                break
            }   
        }   
        fmt.Println(sum)
    }   
}
