using System;
namespace CosnoleApp1
{
    class Project
    {

        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] unos = Console.ReadLine().Split();
            int[] niz = new int[n];
            int []br1=new int[n];
            niz[0] = int.Parse(unos[0]);
            int br=0;
            if (niz[0] == 1) br1[0] = 1;
            else br1[0] = 0;
            for (int i = 1; i < n; i++)
            {
                br1[i] = br1[i - 1];
                if (br1[i] == 1) br1[i]++;
                if (niz[i] == 1 || niz[i] == 2) br++;
                niz[i] = int.Parse(unos[i]);
                
               
            }
            int q = int.Parse(Console.ReadLine());
            int pocetak1, kraj1;
            if (br  == n)
            {
                Console.WriteLine("uso");
                int[] nizgresaka = new int[n];
                nizgresaka[0] = 0;
                for (int i = 1; i < n; i++)
                {
                    nizgresaka[i] = nizgresaka[i - 1];
                    if (niz[i-1] == 2) nizgresaka[i]++;
                }
                for(int i = 0; i < n; i++)
                {
                    Console.WriteLine(nizgresaka[i]);
                }

                unos = Console.ReadLine().Split();
                while (q > 0)
                {
                    pocetak1 = int.Parse(unos[0]) - 1;
                    kraj1 = int.Parse(unos[1]) - 1;
                    if (nizgresaka[kraj1] - nizgresaka[pocetak1] <= 1)


                    {
                        Console.WriteLine("DA");

                    }
                    else if(nizgresaka[kraj1] - nizgresaka[pocetak1] <= 1 && br1[kraj1] - br1[pocetak1]==1)
                    {
                        Console.WriteLine("DA");

                    }
                    else Console.WriteLine("NE");
                    q--;
                    unos = Console.ReadLine().Split();
                }
            }
            else
            {
                int[] nizgresaka = new int[n];
                nizgresaka[0] = 0;
                for (int i = 1; i < n; i++)
                {
                    nizgresaka[i] = nizgresaka[i - 1];
                    if (niz[i] < niz[i - 1]) nizgresaka[i]++;
                }

                unos = Console.ReadLine().Split();
                while (q > 0)
                {
                    pocetak1 = int.Parse(unos[0]) - 1;
                    kraj1 = int.Parse(unos[1]) - 1;
                    if (nizgresaka[kraj1] - nizgresaka[pocetak1] == 1 || nizgresaka[kraj1] - nizgresaka[pocetak1] == 0)


                    {
                        Console.WriteLine("DA");

                    }
                    else Console.WriteLine("NE");
                    q--;
                    unos = Console.ReadLine().Split();
                }
            }
        }
    }
}