import sys sys.setrecursionlimit(10**7) input = sys.stdin.buffer.readline n = int(input()) A = list(map(int, input().split())) if n == 1: q = int(input()) for i in range(q): l, r = map(int, input().split()) print(1, 1) exit() B = [0]*(n-1) for i in range(n-1): B[i] = A[i+1]-A[i] def min_(x, y): if x <= y: return x else: return y def mininit(init_val): # set_val for i in range(n-1): sgmin[i+num-1] = init_val[i] # built for i in range(num-2, -1, -1): sgmin[i] = min_(sgmin[2*i+1], sgmin[2*i+2]) def minupdate(k, x): k += num - 1 sgmin[k] = x while k: k = (k-1)//2 sgmin[k] = min_(sgmin[2*k+1], sgmin[2*k+2]) def minquery(p, q): if q <= p: return ide_ele_min p += num - 1 q += num - 2 res = ide_ele_min while q-p>1: if p&1 == 0: res = min_(res, sgmin[p]) if q&1 == 1: res = min_(res, sgmin[q]) q -= 1 p = p//2 q = (q-1)//2 if p == q: res = min_(res, sgmin[p]) else: res = min_(min_(res, sgmin[p]), sgmin[q]) return res def max_(x, y): if x >= y: return x else: return y def maxinit(init_val): # set_val for i in range(n-1): sgmax[i+num-1] = init_val[i] # built for i in range(num-2, -1, -1): sgmax[i] = max_(sgmax[2*i+1], sgmax[2*i+2]) def maxupdate(k, x): k += num - 1 sgmax[k] = x while k: k = (k-1)//2 sgmax[k] = max_(sgmax[2*k+1], sgmax[2*k+2]) def maxquery(p, q): if q <= p: return ide_ele_max p += num - 1 q += num - 2 res = ide_ele_max while q-p>1: if p&1 == 0: res = max_(res, sgmax[p]) if q&1 == 1: res = max_(res, sgmax[q]) q -= 1 p = p//2 q = (q-1)//2 if p == q: res = max_(res, sgmax[p]) else: res = max_(max_(res, sgmax[p]), sgmax[q]) return res # identity element ide_ele_min = 10**18 ide_ele_max = -10**18 num = 2**(n-2).bit_length() sgmin = [ide_ele_min]*2*num sgmax = [ide_ele_max]*2*num mininit(B) maxinit(B) q = int(input()) for i in range(q): l, r = map(int, input().split()) ans = [0, 0] if minquery(l, r) >= 0: ans[0] = 1 if maxquery(l, r) <= 0: ans[1] = 1 print(*ans)