n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) score = [0] * 101 for ea, eb in zip(a, b): score[eb] += ea if score[0] >= max(score[1:]): ans = "YES" else: ans = "NO" print(ans)