N, *AB = map(int, open(0).read().split())

score = [0] * 101
for a, b in zip(AB[:N], AB[N:]):
    score[b] += a

if all(score[0] >= s for s in score[1:]):
    print("YES")
else:
    print("NO")