n=gets.to_i
a,b=$<.map{|s|s.split.map &:to_i}
c=[0]*999;
n.times{|i|c[b[i]]+=a[i]}
puts c.max==c[0]?:YES: :NO