n=gets.chomp.to_i
a=gets.chomp.split(" ").map{|s| s.to_i}
b=gets.chomp.split(" ").map{|s| s.to_i}
as=a.sort
bs=b.sort
t={}
for i in 0..n-1
  if as[i]>bs[i]
    puts "No"
    exit
  else
    t[as[i]]=bs[i]
  end
end

for i in 0..n-1
  if t[a[i]]==b[i]
    puts "Yes"
    exit
  end
end
puts "No"
