import sys if sys.platform == 'ios': sys.stdin = open('in.txt') sys.setrecursionlimit(10**6) n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=[0]*(n+1) for i in range(n): c[b[i]]+=a[i] if c[0]>=max(c[1:n+1]): print('YES') else: print('NO')