N = int(input()) p = list(map(int, input().split())) s = list(map(int, input().split())) m = [0] * 101 for i, p in enumerate(p): m[s[i]] += p print("YES" if m[0]==max(m) else "NO")