#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

const string YES = "Yes";
const string NO = "No";
//const int oku = 10;

void solve(long long n, std::vector<long long> A, std::vector<long long> B){
    Vi a2=A,b2=B;
    sort(ALL(a2));
    sort(ALL(b2));
    REP(i,0,n){
        if(a2[i]>b2[i]){cout<<NO<<endl;return;}
    }
    REP(i,1,n){
        if(a2[i]<=b2[i-1]){cout<<YES<<endl;return;}
    }

    // multiset<Pii> x,y;
    // REP(i,0,n){
    //     x.insert(mp(A[i],B[i]));
    //     y.insert(mp(a2[i],b2[i]));
    // }
    map<int,int> x,y;
    REP(i,0,n){
        x[A[i]]=B[i];
        y[b2[i]]=a2[i];
    }


    int now=A[0],cnt=0;
    while(1){
        now = x[now];
//        cout<<now<<" ";
        now = y[now];
        // cout<<now<<endl;
        cnt++;
        if(now==A[0]) break;
    }
    // cout<<cnt<<endl;
    if(cnt==n) cout<<NO<<endl;
    else cout<<YES<<endl;

    
    // cout<<"OK1"<<endl;
    // return;

    // Vi a(2*n),b(2*n);
    // VVi connect(2*oku+10);
    // REP(i,0,n){
    //     connect[A[i]].pb(oku+B[i]);
    //     connect[oku+B[i]].pb(A[i]);
    //     connect[a2[i]].pb(oku+b2[i]);
    //     connect[oku+b2[i]].pb(a2[i]);
    // }
    
    // int cnt=0;
    // queue<Tiii> q;
    // q.push(mt(A[0],-1,0));
    // cout<<"OK"<<endl;
    // return;
    // while(!q.empty()){
    //     int now,past,dnow;
    //     tie(now,past,dnow)=q.front();
    //     q.pop();
    //     cout<<cnt<<" "<<now<<endl;
    //     if(cnt!=0 && now==A[0]){cnt++;break;}
    //     cnt++;

    //     if(cnt==0) q.push(mt(B[0],A[0],1));
    //     else{
    //     REP(i,0,connect[now].size()){
    //         if(connect[now][i]!=past) q.push(mt(connect[now][i],now,dnow+1));
    //     }
    //     }

    //     if(cnt==5) break;
    // }
    // if(cnt==2*n) cout<<NO<<endl;
    // else cout<<YES<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    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]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 15872