import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto arra = readln.chomp.split.map!(to!int).array;
    auto arrb = readln.chomp.split.map!(to!int).array;
    
    int[int] mx;
    foreach (i; 0 .. n) {
        if (mx.get(arrb[i], 0) == 0) { mx[arrb[i]] = 0; }
        
        if (arra[i] > arrb[i]) { continue; }
        
        mx[arrb[i]] = max(mx[arrb[i]], arra[i]);
    }
    
    debug { mx.writeln; }
    
    arra.sort();
    arrb.sort();
  
    foreach (i; 0 .. n) {
        if (arra[i] > arrb[i]) {
            writeln("No");
            return;
        }
    }
    
    int idxa = 0, idxb = 0, prev = 0;
    foreach (k; mx.keys.sort()) {
        debug { writeln(k, ' ', mx[k]); }
        
        while (idxa < n && arra[idxa] <= k) { ++idxa; }
        while (idxb < n && arrb[idxb] <= k) { ++idxb; }
        
        if (mx[k] > prev || idxa > idxb) {
            writeln("Yes");
            return;
        }
        
        prev = k;
    }
    
    writeln("No");
    return;
}