N = int(raw_input()) K = 0 score = map(int, raw_input().split()) kai = map(int, raw_input().split()) arr = [ 0 for i in range(101)] for i in range(N): if kai[i] == 0: K += score[i] else: arr[kai[i]] = score[i] if K >= max(arr): print "YES" else: print "NO"