N = int(input()) f = input() s_f = f.split() s = input() s_s = s.split() scores = [int(v) for v in s_f] who = [int(v) for v in s_s] def point(i): b = [v for v,x in enumerate(who) if x == i] c = 0 for v in b: c += scores[v] return c a = set() for i in range(1, 101): a.add(point(i)) top = max(a) d = point(0) if d >= top: print('YES') else: print('NO')