n = gets.to_i scores = gets.split.map(&:to_i) accepts = gets.split.map(&:to_i) result = Hash.new(0) n.times do |i| player = accepts[i] score = scores[i] result[player] += score end score = result[0] max = result.values.max puts score < max ? "NO" : "YES"