from collections import defaultdict as dd n=int(input()) d=dd(int) read=lambda :map(int,input().split()) for i,j in zip(read(),read()): d[j]+=i print("YES" if max(d.values())==d[0] else "NO")