#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

const string YES = "Yes";
const string NO = "No";


map<vector<int>, int> ok[20];


set<vector<int>> perm;

int dfs(vector<int> X, int c) {
    if (ok[c][X]) return 0;
    else ok[c][X]++;
    perm.insert(X);
    if (c == 0) return 0;
    for (int i = 0; i < X.size(); i++) {
        for (int j = i + 1; j < X.size(); j++) {
            auto Y = X;
            swap(Y[i], Y[j]);
            dfs(Y, c - 1);
        }
    }

}

bool solve2(long long N, std::vector<long long> A, std::vector<long long> B) {
    perm.clear();
    for (int i = 0; i < 20; i++) ok[i].clear();

    vector<int> X;
    for (int i = 0; i < N; i++) X.push_back(i);

    {
        vector<int> X;
        for (int i = 0; i < N; i++) X.push_back(i);
        dfs(X, N - 2);
    }

    for (auto i : perm) {
        int cnt = 0;
        for (int j = 0; j < N; j++) {
            if (A[i[j]] <= B[j]) {
                cnt++;
            }
        }
        if (cnt == N) return true;
    }

    return false;
}

bool firstCheck(vector<ll> A, vector<ll> B) {
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for (int i = 0; i < A.size(); i++) {
        if (A[i] > B[i]) return false;
    }
    return true;

}


bool secondCheck(vector<ll> A, vector<ll> B) {
    for (int i = 0; i < A.size(); i++) {
        if (A[i] > B[i]) return false;
    }
    return true;
}

bool thirdCheck(vector<ll> A, vector<ll> B) {
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for (int i = 0; i + 1 < A.size(); i++) {
        if (A[i + 1] <= B[i] && A[i + 1] <= B[i]) return true;
    }
    return false;
}

template<class T>
class Compress {
private:
    vector<T> data;

public:
    Compress(const vector<T> &vec) : data(vec) {
        sort(data.begin(), data.end());
        data.erase(unique(data.begin(), data.end()), data.end());
    }

    T get(int k) {
        assert(k >= 0 && k < data.size());
        return data[k];
    }

    typename vector<T>::iterator lower_bound(const T &t) {
        return ::lower_bound(data.begin(), data.end(), t);
    }

    typename vector<T>::iterator upper_bound(const T &t) {
        return ::upper_bound(data.begin(), data.end(), t);
    }

    int lb_index(const T &t) {
        return lower_bound(t) - data.begin();
    }

    int ub_index(const T &t) {
        return upper_bound(t) - data.begin();
    }

    size_t size() {
        return data.size();
    }
};


class UnionFind {
    std::vector<int> p;

public:
    UnionFind(int n) : p(n, -1) {}

    int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

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

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (p[y] < p[x]) std::swap(x, y);
        if (p[x] == p[y]) --p[x];
        p[y] = x;
        return true;
    }
};

bool solve(long long N, std::vector<long long> A, std::vector<long long> B) {

    if (!firstCheck(A, B)) {
        return false;
    }
    if (secondCheck(A, B)) {
        return true;
    }
    if (thirdCheck(A, B)) {
        return true;
    }
    UnionFind uf(N);
    Compress<ll> cmp1(A);
    Compress<ll> cmp2(B);

    for (int i = 0; i < N; i++) {
        int x = cmp1.lb_index(A[i]);
        int y = cmp2.lb_index(B[i]);
        uf.unite(x, y);
    }
    int cnt = 0;
    for(int i = 0 ; i < N ; i++)
        cnt += uf.root(i) == i;

    return cnt >= 2;
}

void randomTest() {
    while (true) {
        int r = 100000;
        vector<long long> a, b;
        for (int i = 0; i < r; i++) {
            a.push_back(rand() % r + 1);
            b.push_back(rand() % r + 1);
        }

        solve(a.size(), a, b);
    }
}

int main() {
//    randomTest();

    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    std::vector<long long> B(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &B[i]);
    }
    cout << (solve(N, std::move(A), std::move(B)) ? YES : NO) << endl;
    return 0;
}


Measured memory_bytes: 3768