#include #define rep(i,n) for(int i=0;i P; const int INF = 1e9; const int MOD = 1000000007; int main() { int n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; vector up(n),down(n); for(int i=1;i a[i]){ down[i] = down[i-1] + 1; up[i] = 0; }else{ up[i] = up[i-1] + 1; down[i] = down[i-1] + 1; } } int q; cin >> q; rep(i,q){ int l,r; cin >> l >> r; if(up[l]-up[r] == l-r){ cout << 1 << " "; }else{ cout << 0 << " "; } if(down[l]-down[r] == l-r){ cout << 1 << endl; }else{ cout << 0 << endl; } } return 0; }