def lower_bound(array, value)
    left = -1;
    right = array.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if array[mid] > value  #>=
        right = mid
      else
        left = mid
      end
    end
    right
end

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


ab=a.zip(b).sort_by{|x,y| [y,x]}
asroted=a.sort

r = ab.each_with_index.map{|(x,y),i| [x,y,lower_bound(asroted,y)-i-1] }
#p r
if r.none?{|x,y,w| w<0 } and r.each_with_index.any?{|(x,y,w),i| ( i-w<0 || asroted[i-w] <= x) && x <= asroted[i]  }
    print 'Yes'
else
    print 'No'
end
