# No.216 FAC n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] scores = [0] * 101 for i in range(n): scores[b[i]] += a[i] print('YES' if scores[0] >= max(scores[1:]) else 'NO')