N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) player = 0 L = [0 for i in range(100)] for i in range(N) : if B[i] : L[B[i]-1] += A[i] else : player += A[i] if player >= max(L) : print("YES") else : print("NO")