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] print(check) inc = True dec = True for i in range(y - x + 1): a ,b = check[i - 1], check[i] if inc: if a > b: inc = False if dec: if b > a: dec = False if inc: l = "1 " else: l = '0 ' if dec: r = "1" else: r = '0' print(l + r) main()