def check(a2, b2)
    for i in 0...n
        if a2[i] > b2[i]
            return -1
        end
        if a2[i] == b2[i]
            return 1
        end
    end
    return 0
end

n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

aa = a.sort
bb = b.sort
for i in 0...n
    if aa[i] > bb[i]
        puts "No"
        return
    end
end

for i in 0...n
    if a[i] == b[i]
        puts "Yes"
        return
    end
end

for i in 0...n
    for j in i+1...n
        if a[i] == b[j] && a[j] == b[i]
            puts "Yes"
            return
        end
    end
end

puts "No"
