n=int(input()) scores = list(map(int,input().split())) winners = input().split() if not 0 in winners: print("No") exit() dict = {} for i in range(n): if not winners[i] in dict: dict[winners[i]] = scores[i] else: dict[winners[i]] += scores[i] K = dict["0"] rank=[] for key,value in dict.items(): rank.append(value) if K >= max(rank): print("YES") else: print("NO")