n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)

aa = a.sort
bb = b.sort

n.times do |i|
  if aa[i] > bb[i]
    puts 'No'
    exit
  end
end

1.upto(n) do |i|
  index = aa.index(i)
  if index == 0 && i != n
    puts 'Yes'
    exit
  end
end

(n-1).times do |i|
  if aa[i+1] <= bb[i]
    puts 'Yes'
    exit
  end
end
puts 'No'
