#216 FAC N=int(input()) a=[int(i) for i in input().split()] b=[int(i) for i in input().split()] M=[]*100 K=0 for i in range(len(b)-1): if b[i]>0: M[b[i]]+=a[i] else: K+=a[i] S=0 for i in range(len(a)-1): S+=a[i] Ma=0 for i in range(len(M)-1): if Ma=Ma: print("YES") else: print("NO")