module simple;import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, core.stdc.string;

immutable long MOD = 998244353;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    auto B = readln.split.map!(to!int).array;

    auto C = A.dup.sort().array;
    auto D = B.dup.sort().array;
    if (N.iota.map!(i => C[i] > D[i]).any) {
        writeln("No");
        return;
    }

    auto X = N.iota.map!(i => tuple(i, A[i])).array;
    auto Y = N.iota.map!(i => tuple(i, B[i])).array;
    X.sort!"a[1] < b[1]";
    Y.sort!"a[1] < b[1]";

    foreach (i; 0..N-1) {
        if (X[i][1] <= Y[i+1][1] && X[i+1][1] <= Y[i][1]) {
            writeln("Yes");
            return;
        }
    }

    writeln("No");
}
