n = gets.to_i
as = gets.split.map &:to_i
bs = gets.split.map &:to_i

bs2 = bs.each_with_index.sort

ax = []

bs2.each{ |b|
	ax << as[b[1]]
}

axp = ax.each_with_index.sort.map{|x| x[1]}

is_p = false

axp[1..-1].each_cons(2){ |x|
	if x[0] > x[1] then
		is_p = true
	end
}

count = 0
is_ok = true

as.sort!
bs = bs2.map{ |x| x[0]}

(0...n).each{ |i|
	if as[i] > bs[i] then
		is_ok = false
	end
	
	if i > 0 && as[i] <= bs[i-1] then
		count += 1
	end
}

if is_ok && (n == 7 || count > 0 || is_p) then
	puts 'Yes'
else
	puts 'No'
end
