N=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) l=[0]*101 for i in range(N): l[b[i]]+=a[i] if l[0]==max(l): print('YES') else: print('NO')