n = int(input()) a_s = list(map(int, input().split())) b_s = list(map(int, input().split())) lst = [0 for _ in range(100)] point = 0 for a, b in zip(a_s, b_s): if b == 0: point += a else: lst[b - 1] += a if point >= max(lst): print("YES") else: print("NO")