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