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]";
    auto next = new int[](N);
    auto uf = new UnionFind(N);

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

    foreach (i; 0..N) {
        uf.unite(X[i][0], Y[i][0]);
    }

    if (uf.table.map!(a => a < 0).sum > 1) {
        writeln("Yes");
    } else {

        writeln("No");
    }
}

class UnionFind {
    import std.algorithm : swap;

    int n;
    int[] table;

    this(int n) {
        this.n = n;
        table = new int[](n);
        table[] = -1;
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
}