using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力開始
            int N = int.Parse(Console.ReadLine());
            string[] str1 = Console.ReadLine().Split(' ');
            int[] x = new int[N];
            for (int i = 0; i < N; i++)
            {
                x[i] = int.Parse(str1[i]);
            }
            int L = int.Parse(Console.ReadLine());
            int Q = int.Parse(Console.ReadLine());
            int[] a = new int[Q];
            int[] b = new int[Q];
            string[] str2 = new string[2];
            for (int i = 0; i < Q; i++)
            {
                str2 = Console.ReadLine().Split(' ');
                a[i] = int.Parse(str2[0]);
                b[i] = int.Parse(str2[1]);
            }
            //入力完了

            /*入力検査
            Console.WriteLine("\n");
            Console.WriteLine(N);
            for (int i = 0; i < N; i++)
            {
                Console.Write(x[i]);
                Console.Write(" ");
            }
            Console.Write("\n");
            Console.WriteLine(L);
            Console.WriteLine(Q);
            for (int i = 0; i < Q; i++)
            {
                Console.Write("{0} {1}\n", a[i], b[i]);
            }
            入力検査終了*/

            /*//旧タイプdays計算開始
            for (int j = 0; j < Q; j++)
            {
                int[] sampleArray = sample(x, a[j], b[j]);
                int daysValue = days(sampleArray, L);
                Console.WriteLine(daysValue);

                sample検査
                for (int i = 0; i < sampleArray.Length;i++)
                {
                    Console.Write("\n");
                    Console.Write("\n");
                }
                sample検査終了
          　 }
            //旧タイプdays計算終了*/

            //新タイプdays計算開始
            for (int j = 0; j < Q; j++)
            {
                int days = daysAlt(x, a[j], b[j], L);
                Console.WriteLine(days);
            }
            //新タイプdays計算終了
        }
        internal static int[] sample(int[] x, int a, int b )
        {
            a -= 1;
            b -= 1;
            int absolute = System.Math.Abs(b - a);
            int[] sample = new int[absolute + 1];
            for (int i = 0; i < absolute + 1; i++)
            {
                sample[i] = x[i + Math.Min(b,a)];
            }
            return sample;
        }
        internal static int days(int[] sample, int L)
        {
            int days = 0;
            int start = 0;
            int relay = 1;

            int flag = 0;
            while (flag == 0)
            {
                while ((relay < sample.Length) && (sample[relay] - sample[start] <= L))
                {
                    relay++;
                }
                if ((relay < sample.Length) && (sample[relay] - sample[start] > L))
                {
                    days++;
                    start = relay-1;
                }
                else
                {
                    days++;
                    flag = 1;
                }
            }
            return days;
        }
        internal static int daysAlt(int[] x, int a, int b, int L)
        {
            a -= 1;
            b -= 1;
            int A = Math.Min(b,a);
            int B = Math.Max(b, a);
            int days = 0;
            int start = A;
            int relay = A + 1;


            while ((relay < B + 1) && (x[relay] - x[start] <= L))
            {
                relay++;
            if ((relay < B + 1) && (x[relay] - x[start] > L))
            {
                days++;
                start = relay - 1;
                continue;
            }

            }
        if(relay > B)
        {
            days++;   
        }
            return days;
        }
        /*internal static int daysAlt2(int[] x, int a, int b, int L)
        {
            a -= 1;
            b -= 1;
            int A = Math.Min(b, a);
            int B = Math.Max(b, a);
            int days = 0;
            int start = A;
            int relay = A + 1;
            for (int i = 0; i < )
        }*/
    }
}
