n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

dic = {}

for i in range(n):
    if B[i] not in dic:
        dic[B[i]] = A[i]
    else:
        dic[B[i]] += A[i]

ans = sorted(dic.items(), key=lambda x:(-x[1], x[0]))

if ans[0][0] == 0:
    print('YES')
else:
    print('NO')