N = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) score = [0]*101 for i in range(N): score[b[i]] += a[i] if score[0] == max(score): print("YES") else: print("NO")