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