n=int(input()) d={i:0 for i in range(n)} 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")