n = int(input()) ls_1 = list(map(int, input().split())) ls_2 = list(map(int, input().split())) nobishiro = 0 for i in range(n): if ls_2[i] == 0: nobishiro += ls_1[i] highest = 0 others = [] for i in range(n): if ls_2[i] != 0: for other in others: if ls_2[i] == other[0]: other[1] += ls_1[i] break else: others.append([ls_2[i], ls_1[i]]) for other in others: if other[1] > highest: highest = other[1] if nobishiro >= highest: print('YES') else: print('NO')