n = input().strip() a = [int(i) for i in input().strip().split(' ')] b = input().strip().split(' ') dic = {} for x, y in zip(a, b): try: dic[y] += x except: dic[y] = x if dic['0'] >= max([i for i in dic.values()]): print('YES') else: print('NO')