from itertools import accumulate N = int(input()) A = list(map(int, input().split())) B = [0] * N C = [0] * N ans = [0, 1] for i in range(1, N): if A[i - 1] <= A[i]: B[i] = 1 if A[i - 1] >= A[i]: C[i] = 1 B = list(accumulate(B)) C = list(accumulate(C)) for _ in range(int(input())): l, r = map(int, input().split()) print(ans[B[r] - B[l] == r - l], ans[C[r] - C[l] == r - l])