n=int(input()) a=[x for x in map(int,input().split())] b=[x for x in map(int,input().split())] d=[] s=[0]+sorted(list(set(b))) for i in s: c=[j for j, x in enumerate(b) if x==i] v=0 for j in c: v+=a[j] d+=[v] print("YNEOS"[d[0]