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 c = 0 try: c = dic['0'] except: pass if c >= max([i for i in dic.values()]): print('YES') else: print('NO')