#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    long long n;
    cin >> n;
    long long a[n];
    for(long long i = 1; i <= n; i++) cin >> a[i];
    long long q;
    cin >> q;
    long long b[q], c[q];
    for(long long i = 1; i <= q; i++)
    {
        long long br = 0;
        cin >> b[i] >> c[i];
        for(long long j = b[i]; j < c[i]; j++)
        {
            cout << a[j] << " " << a[j + 1] << endl;
            if(a[j] > a[j + 1])
            {
                if(a[j + 1] < a[j - 1])
                {
                    cout << "NE" << endl;
                    break;
                }
                else br++;
            }
        }
        if(br == 0 || br == 1)
        {
            cout << br << endl;
            cout << "DA" << endl;
        }
        else
        {
            cout << br << endl;
            cout << "NE" << endl;
        }
        continue;
    }
    return 0;
}