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

cnt = 0
ans = 'Yes'
N.times do |i|
  cnt += 1 if A[i] <= B[i]
  if AA[i] > BB[i]
    ans = 'No'
    break
  end
end
ans = 'No' if cnt < 2
puts ans
