import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;

alias AB = Tuple!(int, "a", int, "b");

void main()
{
    auto N = readln.chomp.to!int;
    auto ab = new AB[](N);
    auto as = new int[](N);
    foreach (i, a; readln.split.to!(int[])) {
        ab[i].a = a;
        as[i] = a;
    }
    foreach (i, b; readln.split.to!(int[])) ab[i].b = b;
    sort!"a.b < b.b"(ab);
    sort(as);
    bool ok;
    foreach (i; 0..N) {
        if (as[i] > ab[i].b) {
            writeln("No");
            return;
        } else if (as[i] == ab[i].a) {
            ok = true;
        }
    }
    if (ok) {
        writeln("Yes");
        return;
    }
    foreach (i; 0..N-1) {
        if (as[i+1] <= ab[i].b) {
            writeln("Yes");
            return;
        }
    }
    writeln("No");
}