# -*- coding: utf-8 -*- N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) scores = [0]*101 for i in range(N): scores[b[i]] += a[i] print('YES') if scores.index(max(scores))==0 else print('NO')