N=int(input()) A=list(map(int,input().split())) Q=int(input()) Query=[list(map(int,input().split())) for i in range(Q)] LEN=N+5 BIT=[0]*(LEN+1)# 1-indexedなtree def update(v,w):# index vにwを加える while v<=LEN: BIT[v]+=w v+=(v&(-v))# 自分を含む大きなノードへ. たとえばv=3→v=4 def getvalue(v):# [1,v]の区間の和を求める ANS=0 while v!=0: ANS+=BIT[v] v-=(v&(-v))# 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ return ANS BIT2=[0]*(LEN+1)# 1-indexedなtree def update2(v,w):# index vにwを加える while v<=LEN: BIT2[v]+=w v+=(v&(-v))# 自分を含む大きなノードへ. たとえばv=3→v=4 def getvalue2(v):# [1,v]の区間の和を求める ANS=0 while v!=0: ANS+=BIT2[v] v-=(v&(-v))# 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ return ANS for i in range(1,N): if A[i]>=A[i-1]: update(i,1) if A[i]<=A[i-1]: update2(i,1) for x,y in Query: if getvalue(y)-getvalue(x)==y-x: print(1,end=" ") else: print(0,end=" ") if getvalue2(y)-getvalue2(x)==y-x: print(1) else: print(0)