#include <bits/stdc++.h>

using namespace std;

int n;

bool solve(int *a, int l, int d) {
    int br = 1;
    for(int i=l; i<d; ++i) {
        if(a[i] > a[i+1]) {
            if(br)
                br--;
            else
                return false;
        }
    }
    return 1;
}

int main(void) {

    cin >> n;
    int a[n];
    int s[n];
    s[n-1] = 0;

    cin >> a[0];
    for(int i=1; i<n; ++i) {
        cin >> a[i];
        int k = i-1;
        int br = 0;
        bool done = false;
        while(k >= 0 && br != -1) {
            if(a[k] > a[i]) br--;
            if(a[k] == a[i]) {
                s[i] = s[k];
                done = true;
                break;
            }
            k--;
        }
        if(!done)
            s[i] = (k != -1 ? k : 0);
    }

    //for(int i=1; i<n; ++i) {
    //    s[i] += s[i-1];
    //}
    for(int i=0; i<n; ++i) {
        cout << s[i] << " ";
    }
    cout << endl;

    int q;
    cin >> q;

    while(q--) {
        int l, r;
        cin >> l >> r;
        l -= 1;
        r -= 1;

        if(l < s[r]) cout << "NE\n";
        else cout << "DA\n";
    }

    return 0;
}