n=gets.to_i
aa=gets.split.map(&:to_i)
bb=gets.split.map(&:to_i)
ba=[]
n.times do |i|
  ba<<[bb[i],aa[i]]
end
ba.sort!
a=[]
b=[]
ba.each do |bbb,aaa|
  a << aaa
  b << bbb
end
c=a.sort
f1=false
f2=true
n.times do |i|
  if c[i]<=a[i]&&a[i]<=b[i]
    f1=true
  end
  if c[i]>b[i]
    f2=false
  end
end
puts f1&&f2 ? "Yes" : "No"
