#include<iostream>
using namespace std;
 int main(){
    int n, q;
    cin >> n;
    int niz[n];
    for (int i=0;i<n;i++){
        cin >> niz[i];
    }
    cin >> q;
    int br=0;
    for (int i=1;i<n;i++){
        if (niz[i]<niz[i-1]) {br=br+1;}
    }
    
    int kriticni[br];
    int t=0;
    for (int i=1;i<n;i++){
        if (niz[i]<niz[i-1]) {kriticni[t]=i+1;t=t+1;}
    }
    for (int i=0;i<br;i++){
    	cout << kriticni[i] << " ";
    }
    cout << "\n";
    cout << "\n";
    int l,r;
    int x;
    int levi1,desni1;
    int levi2,desni2;
    int index1,index2;
    int sredina1,sredina2;
    for (int i=0;i<q;i++){
        x=0;
        index1=0;
        index2=0;
        cin >> l >> r;
        levi1=0;
        desni1=br-1;
        while (levi1<=desni1){
            sredina1=levi1+(desni1-levi1)/2;
            if (kriticni[sredina1]>l){
                index1=sredina1;
                desni1=sredina1-1;
            }
            else {levi1=sredina1+1;}
        }
        	cout << index1 << " ";
        	levi2=0;
        	desni2=br-1;
        	while (levi2<=desni2){
            	sredina2=levi2+(desni2-levi2)/2;
            	if (kriticni[sredina2]<=r){
                	index2=sredina2+1;
                	levi2=sredina2+1;
            	}
            	else {desni2=sredina2-1;}
        	}
        	cout << index2 << " ";
        	x=index2-index1;
        	if (x<=1) {cout << "DA" << "\n";}
        	else {cout << "NE" << "\n";}

 
    }
    return 0;
 }