#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define rng(a) a.begin(),a.end() using namespace std; typedef long long int ll; typedef pair P; typedef vector vi; typedef vector vvi; typedef vector vl; typedef vector

vp; #define dame { puts("-1"); return 0;} #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { int n; cin >> n; ll a[n]; rep(i,n)cin >> a[i]; int q; cin >> q; int l[q], r[q]; rep(i,q) cin >> l[i] >> r[i]; int up[n] = {}; rep(i,n){ if(i == 0){ ; }else{ if(a[i-1] <= a[i]){ up[i] = up[i-1]; }else{ up[i] = i; } } } int down[n] = {}; rep(i,n){ if(i == 0){ ; }else{ if(a[i-1] >= a[i]){ down[i] = down[i-1]; }else{ down[i] = i; } } } rep(i,q){ if(up[r[i]] <= l[i])cout << "1 "; else cout << "0 "; if(down[r[i]] <= l[i]) cout << '1' << endl; else cout << '0' << endl; } return 0; }