#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[200000];
    vector<int> r;
    vector<int> rp;
    int j = 0;
    int max = 0;
    int max1 = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] >= max && a[i] > max1) {
            max = a[i];
            max1 = 0;
        }
        else if (a[i] >= max && a[i] == max1) {
            rp.push_back(i);
            max = a[i];
            max1 = a[i];
        }
        else {
            r.push_back(i);
            max = a[i];
            max1 = a[i];
        }
    }
    int q, l, d, i = 0, k = 0, br = 0, brp = 0;
    cin >> q;
    while (q > i) {
        i++;
        cin >> l >> d;
        while (d >= r[k] && br <= 1) {
            if (l <= r[k] - 1 && d >= r[k]) {
                br++;
            }
            k++;
        }
        k = 0;
        while (d >= rp[k] && br <= 1) {
        if (l <= rp[k] - 3 && d >= rp[k]) {
                brp++;
            }
        k++;
            
        }
        if (br + brp > 1) {
            cout << br << endl;
        }
        else {
            cout << "DA" << endl;
        }
        k = 0;
        br = 0;
        brp = 0;
    }
}