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