#include using namespace std; #define int long long #define REP(i,n) for(int i = 0;i < (int)(n);i++) #define FOR(i,s,n) for(int i = s;i < (int)n;i++) #define RREP(i,n) for(int i = (int)n-1;i >= 0;i--) templateinline bool CHMAX(T&a,T b){if(ainline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;} signed main(){ int N; cin >> N; vector a(N); for(auto& e:a)cin >> e; vectorup(N,N-1); RREP(i,N-1){ if(a[i]<=a[i+1])up[i]=up[i+1]; else up[i]=i; } vectorlo(N,0); FOR(i,1,N){ if(a[i-1]>=a[i])lo[i]=lo[i-1]; else lo[i]=i; } vector>ans; int Q; cin >> Q; while(Q--){ int l,r; cin >> l >> r; pairp={0,0}; if(up[l]>=r)p.first = 1; if(lo[r]<=l)p.second = 1; ans.push_back(p); } for(auto e:ans){ cout<