#!/usr/bin/python from collections import defaultdict n = int(raw_input()) a = map(int, raw_input().split()) b = map(int, raw_input().split()) dic = defaultdict(int) for i in xrange(n): dic[b[i]] += a[i] if dic[0] >= max(dic.values()): res = 'YES' else: res = 'NO' print res