def read_data(): N = int(input()) As = list(map(int, input().split())) Bs = list(map(int, input().split())) return N, As, Bs def solve(N, As, Bs): d = [0] * 101 for a, b in zip(As, Bs): d[b] += a if max(d) == d[0]: print('YES') else: print('NO') N, As, Bs = read_data() solve(N, As, Bs)