N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

diff_cnt = A.zip(B).count { |a, b| a > b }

if diff_cnt <= N - 2 && A.sort.zip(B.sort).all? { |a, b| a <= b }
  puts 'Yes'
else
  raise
end
