from collections import defaultdict n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) score = defaultdict(int) for s, p in zip(a, b): score[p] += s if score[0] < max(score.values()): print('NO') else: print('YES')