import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) A = np.array(readline().split(),np.int64) B = np.array(readline().split(),np.int64) A,B score = np.zeros(101,np.int64) np.add.at(score,B,A) answer = 'YES' if score[0] == score.max() else 'NO' print(answer)