#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 50;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
//UnionFind
//How to use
//unite(x,y) : 集合 x と y を併合する. 併合済のとき false, 未併合のとき true が返される
//find(k) : 要素 k が属する集合を求める
//size(k) : 要素 k が属する集合の要素の数を求める
struct UnionFind {
    vector<int> data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};


bool dbg = false;
int N;
itn A[101010], B[101010];
vector<P> V;
vector<P> A2, B2;

void solve() {
    V.resize(N);
    FOR(N) {
        V[i] = P{A[i], B[i]};
    }
    A2.resize(N);
    B2.resize(N);
    FOR(N) {
        A2[i] = {A[i], i};
        B2[i] = {B[i], i};
    }
    sort(all(V));
    sort(A, A + N);
    sort(B, B + N);
    sort(all(A2));
    sort(all(B2));
    bool flag = true;
    FOR(i, 0, N) {
        if (A[i] > B[i])
            flag = false;
    }
    if (!flag) {
        No();
        return;
    }
    bool flag2 = false;
    FOR(i, 0, N - 1) {
        if (A[i + 1] <= B[i])
            flag2 = true;
    }
    FOR(i, 0, N) {
        if (B[i] == V[i].second)
            flag2 = true;
    }
    if (flag2) {
        Yes();
        return;
    }

    UnionFind uf(N);
    FOR(N) {
        uf.unite(A2[i].second, B2[i].second);
    }
    Yes(uf.size(0) < N);


    return;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(N)
    cin >> A[i];
    FOR(N)
    cin >> B[i];


    solve();
    return 0;
}


Measured memory_bytes: 7296