#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let x = read_vec::<i64>();
    let l = read::<i64>();
    let mut queries = vec![];
    let q = read::<usize>();
    for _ in 0..q {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        queries.push((min(a, b), max(a, b)));
    }
    let max_log_n = 16;
    let mut next = vec![vec![0; n]; max_log_n];
    next[0][n - 1] = n - 1;
    for i in 0..n - 1 {
        next[0][i] = x.upper_bound(&(x[i] + l)) - 1;
    }
    for ni in 1..max_log_n {
        next[ni][n - 1] = n - 1;
        for j in 0..n - 1 {
            next[ni][j] = next[ni - 1][next[ni - 1][j]];
        }
    }

    for (mut a, b) in queries {
        let mut ans = 0;
        for ni in (0..max_log_n).rev() {
            if next[ni][a] < b {
                a = next[ni][a];
                ans += 1 << ni;
            }
        }
        if a < b {
            a = next[0][a];
            ans += 1;
        }
        assert!(a >= b);
        println!("{}", ans);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}
