// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

bool check_1(vector<int> A, vector<int> B) {
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int N = A.size(), ok = true;
    for(int i=0; i<N; i++) {
        ok &= (A[i] <= B[i]);
    }
    return ok;
}

void modify_1(vector<int> &A, vector<int> &B) {
    vector< pair<int, int> > seg;
    int N = A.size();
    for(int i=0; i<N; i++) {
        seg.emplace_back(B[i], A[i]);
    }
    sort(seg.begin(), seg.end());

    // B 昇順に
    for(int i=0; i<N; i++) {
        int x, y; tie(y, x) = seg[i];
        A[i] = x, B[i] = y;
    }
}

pair< vector<int>, vector<int> > extract_1(vector<int> A) {
    int N = A.size();
    vector<int> B = A;
    sort(B.begin(), B.end());

    // ソート後の A と異なる場所を抽出
    int ptr = 0;
    vector< pair<int, int> > X;
    vector<int> Y;
    for(int i=0; i<N; i++) {
        // if(A[i] == B[i]) continue;
        X.emplace_back(A[i], ptr++);
        Y.emplace_back(A[i]);
    }
    sort(X.begin(), X.end());

    N = X.size();
    vector<int> P(N);
    // k 番目にあるものは、i 番目に行きたい
    for(int i=0; i<N; i++) {
        int k = X[i].second;
        P[k] = i;
    }
    return make_pair(P, Y);
}

int main() {
    int N; cin >> N;    
    int lim = N - 2;
    vector<int> A(N), B(N), comp;
    for(int i=0; i<N; i++) cin >> A[i], comp.emplace_back(A[i]);
    for(int i=0; i<N; i++) cin >> B[i], comp.emplace_back(B[i]);
    
    sort(comp.begin(), comp.end());
    comp.erase(unique(comp.begin(), comp.end()), comp.end());
    for(int i=0; i<N; i++) {
        A[i] = lower_bound(comp.begin(), comp.end(), A[i]) - comp.begin();
        B[i] = lower_bound(comp.begin(), comp.end(), B[i]) - comp.begin();
    }

    // 自明に可能なやつ
    if(*min_element(B.begin(), B.end()) >= *max_element(A.begin(), A.end())) {
        cout << "Yes" << endl;
        return 0;
    }

    // 自明に不可能なやつ
    bool ok = check_1(A, B);
    modify_1(A, B);

    // 可能なやつ (i と i+1 の順序がどうでもよいもの)
    {
        vector<int> S = A;
        sort(S.begin(), S.end());
        for(int i=0; i+1<N; i++) {
            if(S[i+1] <= B[i] and ok) {
                cout << "Yes" << endl;
                return 0;
            }       
        }
    }

    // ソート後の A とソート前の A で、異なるところのみを抜き出して置換を得る
    vector<int> X, Y;
    tie(X, Y) = extract_1(A);

    N = X.size();
    int M = comp.size();
    vector<int> visited(N), cnt(M);
    int ans = 0;
    fprintf(stderr, "N = %d\n", N);
    for(int i=0; i<N; i++) {
        if(visited[i]) continue;
        vector<int> loop;
        int cur = i;
        while(!visited[cur]) {
            visited[cur] = true;
            cnt[ Y[cur] ]++;
            loop.emplace_back(cur);
            cur = X[cur];
        }
        for(auto e : loop) {
            cerr << e << " ";
            if(cnt[ Y[e] ] > 1) {
                puts("Yes");
                return 0;
            }
        }
        cerr << endl;
        ans += (int)loop.size() - 1;

        for(auto e : loop) --cnt[ Y[e] ];
    }

    ok &= (ans <= lim);
    cerr << "? " << ans << endl;
    printf("%s\n", ok ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 5224