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:
            check = A[x : y +1]
            inc = True
            dec = True

            for i in range(len(check)-1):
                a ,b = check[i ], check[i + 1]
                if inc:
                    if a > b:
                        inc = False

                if dec:
                    if b > a:
                        dec = False
                if (dex == False) and (inc == False):
                    print("0 0")
                    break
            if inc:
                l = "1 "
            else:
                l = '0 '
            if dec:
                r = "1"
            else:
                r = '0'
            print(l + r)

main()