n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = [0] * 101 for i in range(n): c[b[i]] += a[i] print("YES" if c[0] >= max(c) else "NO")