N = input() problems = map(int, raw_input().split()) solvers = map(int, raw_input().split()) scorelist = [0] * 105 for s in solvers: scorelist[s] += problems[s] if max(scorelist) == scorelist[0]: print 'YES' else: print 'NO'