#!/usr/bin/env python3
#fileencoding: utf-8

N = int(input())
a = [int(i) for i in input().strip().split(" ")]
b = [int(i) for i in input().strip().split(" ")]

K = 0
others = {}
others_max = 0
for i,j in zip(a,b):
    if j == 0:
        K += i
    else:
        if j not in others:
            others[j] = 0
        others[j] += i
        if others_max < others[j]:
            others_max = others[j]

print("YES" if K >= others_max else "NO")