def main(): N = int(input()) A = list(map(int, input().split())) Q = int(input()) up = [0] * N down = [0] * N cnt = 0 for i in range(N-1): if A[i] <= A[i+1]: cnt += 1 up[i+1] = cnt else: cnt = 0 cnt = 0 for i in range(N-1): if A[i] >= A[i+1]: cnt += 1 down[i+1] = cnt else: cnt = 0 for _ in range(Q): l, r = map(int, input().split()) f = up[r] - up[l] g = down[r] - down[l] ans = [0,0] if f == r - l: ans[0] = 1 if g == r - l: ans[1] = 1 print(*ans) if __name__ == "__main__": main()