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

r = 0

N.times do |i|
    if A[i-1] > B[i-1]
       r += 1
    end
end

A2 = A.sort!
B2 = B.sort!

def yes?
   N.times do |i|
        if A2[i-1] > B2[i-1]
            puts 'No'
            break
        end
    end
end

M = N - 2

if yes? && r <= M
    puts 'Yes'
elsif yes?  && r > M
    puts 'No'
end