using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
using System.Text;

namespace ARC060E_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var x = ReadInts;

            int L = ReadInt;
            int logN = (int)Math.Log(N, 2) + 1;
            int[,] dp = new int[logN, N];
            for (int i = 0; i < N; i++)
            {
                int max = x[i] + L;
                int index = UpperBound(x, max) - 1; //その日にいける一番遠い宿
                dp[0, i] = index;
            }

            //2^k先まで算出
            for (int k = 0; k < logN - 1; k++)
            {
                for (int i = 0; i < N; i++)
                {
                    dp[k + 1, i] = dp[k, dp[k, i]];
                }
            }

            //チェック
            //DrawMapforDebug(dp);

            int Q = ReadInt;
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < Q; i++)
            {
                int from = ReadInt - 1;
                int to = ReadInt - 1;
                //from<toにする。
                if (from > to)
                {
                    int temp = from;
                    from = to; to = temp;
                }

                //計算
                int ans = 1;
                for (int k = logN - 1; k >= 0; k--)
                {
                    if (from == to) break;

                    //そこまで行く
                    if (dp[k, from] < to)
                    {
                        ans += (int)Math.Pow(2, k);
                        from = dp[k, from];
                    }
                    //行かない
                    else
                    {
                        continue;
                    }
                }

                sb.AppendLine(ans.ToString());
            }

            Console.WriteLine(sb);

        }
        /// <summary>
        /// 二分探索 keyより大きい最低
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="a"></param>
        /// <param name="v"></param>
        /// <returns></returns>
        public static int UpperBound<T>(T[] a, T v)
        {
            return UpperBound(a, v, Comparer<T>.Default);
        }

        public static int UpperBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res <= 0) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }

    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void DrawMapforDebug(int[,] map, int mode = 1)
        {
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }

        static void DrawArrayforDebug(int[] array, int mode = 0)
        {
            Console.WriteLine(string.Join(" ", array));
        }
    }
}


Measured memory_bytes: 38532