N = int(input()) lsA = list(map(int,input().split())) lsB = list(map(int,input().split())) ls = [0]*101 for i in range(N): ls[lsB[i]] += lsA[i] K = ls[0] if K >= max(ls): print('YES') else: print('NO')