N = int(input()) A = [int(k) for k in input().split()] Q = int(input()) def main(): for p in range(Q): x, y = [int(k) for k in input().split()] if (x == y): print("1 1") else: inc = True dec = True t = True for i in range(x, y -1): a ,b = A[i], A[i + 1] if inc: if a > b: inc = False if dec: if b > a: dec = False if (not dec) and (not inc): t = False print("0 0") break if t: if inc: l = "1 " else: l = '0 ' if dec: r = "1" else: r = '0' print(l + r) main()