#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    vector<pp> aa(n),bb(n);
    rep(i,n){
        aa[i]=mk(a[i],i);
        bb[i]=mk(b[i],i);
    }
    sort(all(aa));
    sort(all(bb));
    rep(i,n){
        if (aa[i].first>bb[i].first) {cout << "No" << endl;return 0;}
    }
    int e=n,x=0;
    vector<int> g(n),gg(n);
    rep(i,n) {
        g[aa[i].second]=i;
        gg[i]=bb[i].second;
    }
    while(true){
        // cout << x << endl;
        if (gg[g[x]]==0) break;
        x=gg[g[x]];
        e--;
    }
    if (e>1) {cout << "Yes" << endl;return 0;}
    rep(i,n-1){
        if (aa[i+1].first<=bb[i].first) {cout << "Yes" << endl;return 0;}
    }
    cout << "No" << endl;
}
