using System;
using System.Collections.Generic;
using System.Text;
using CompLib.Util;

public class Program
{
    private int N;
    private int[] X;
    private int L;
    private int Q;
    private int[] A, B;

    // iから2^j日で行けるホテル H[i][j]
    private List<int>[] Hotel;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        X = sc.IntArray();
        L = sc.NextInt();
        Q = sc.NextInt();
        A = new int[Q];
        B = new int[Q];
        for (int i = 0; i < Q; i++)
        {
            A[i] = sc.NextInt() - 1;
            B[i] = sc.NextInt() - 1;

            if (A[i] > B[i])
            {
                int t = A[i];
                A[i] = B[i];
                B[i] = t;
            }
        }

        Hotel = new List<int>[N];
        for (int i = N - 1; i >= 0; i--)
        {
            Hotel[i] = new List<int>();
            if (i == N - 1) continue;
            // 1日で行けるホテル
            int ok = i + 1;
            int ng = N;
            while (ng - ok > 1)
            {
                int mid = (ok + ng) / 2;
                if (X[mid] <= X[i] + L ) ok = mid;
                else ng = mid;
            }

            Hotel[i].Add(ok);
            int cur = ok;
            while (Hotel[i].Count <= Hotel[cur].Count)
            {
                int next = Hotel[cur][Hotel[i].Count - 1];
                Hotel[i].Add(next);
                cur = next;
            }
        }

        var sb = new StringBuilder();
        for (int i = 0; i < Q; i++)
        {
            // めんd
            int ng = 0;
            int ok = N;
            while (ok - ng > 1)
            {
                int mid = (ok + ng) / 2;
                if (C(A[i], mid) >= B[i]) ok = mid;
                else ng = mid;
            }

            sb.AppendLine(ok.ToString());
        }
        Console.Write(sb.ToString());
    }

    // ホテルbからd日で行けるホテル
    int C(int b, int d)
    {
        if (d == 0 || b == N - 1) return b;
        for (int i = Hotel[b].Count - 1; i >= 0; i--)
        {
            int p = 1 << i;
            if (p <= d) return C(Hotel[b][i], d - p);
        }

        throw new Exception();
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 64712