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