#include using namespace std; typedef long long ll; typedef pair l_l; typedef pair i_i; template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; int N; int A[100500]; int B[100500]; int C[100500]; int Bsum[100500]; int Csum[100500]; int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); cin >> N; for(int i = 0; i < N; i++) cin >> A[i]; for(int i = 1; i < N; i++) { Bsum[i] = Bsum[i-1]; Csum[i] = Csum[i-1]; if(A[i] >= A[i-1]) Bsum[i]++; if(A[i] <= A[i-1]) Csum[i]++; } int Q; cin >> Q; while(Q--) { int l, r; cin >> l >> r; if(Bsum[r] - Bsum[l] == r - l) cout << 1; else cout << 0; cout << " "; if(Csum[r] - Csum[l] == r - l) cout << 1; else cout << 0; cout << endl; } return 0; }