N = int(raw_input()) score = map(int,raw_input().split()) solve = map(int,raw_input().split()) solver = [0 for i in range(100+ 1)] for i in range(N): solver[solve[i]] += score[i] solver[0] = sum([score[i] for i in range(N) if solve[i] == 0]) if solver[0] == max(solver): print "YES" else: print "NO"