#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll MAXN = 1e5 + 10;
pair<ll,ll> a[MAXN];

bool cmp(pair<ll,ll> a,pair<ll,ll> b){
    if(a.second == b.second) return a.first < b.first;
    else return a.second < b.second;
}

pair<ll,ll> seg_min[4*MAXN];
pair<ll,ll> seg_max[4*MAXN];

void update(ll node,ll s,ll e,ll pos,ll val){

    if(s > e) return;

    if(s == e){
        seg_min[node] = {val,pos};
        seg_max[node] = {val,pos};
        return;
    }

    ll mid = (s+e)>>1;
    if(pos <= mid) update(2*node,s,mid,pos,val);
    else update(2*node+1,mid+1,e,pos,val);

    seg_max[node] = max(seg_max[2*node],seg_max[2*node+1]);
    seg_min[node] = min(seg_min[2*node],seg_min[2*node+1]);   
}

pair<ll,ll> query_min(ll node,ll s,ll e,ll qs,ll qe){
    if(s > e || qs > e || qe < s) return {1e10,0};

    if(qs <= s && e <= qe){
        return seg_min[node];
    }

    ll mid = (s+e)>>1;
    return min(query_min(2*node,s,mid,qs,qe),query_min(2*node+1,mid+1,e,qs,qe));
}

pair<ll,ll> query_max(ll node,ll s,ll e,ll qs,ll qe){
    if(s > e || qs > e || qe < s) return {0,0};

    if(qs <= s && e <= qe){
        return seg_max[node];
    }

    ll mid = (s+e)>>1;
    return max(query_max(2*node,s,mid,qs,qe),query_max(2*node+1,mid+1,e,qs,qe));
}

void solve(){
    ll n; cin>>n;

    FOR(i,1,n) cin>>a[i].first;
    FOR(i,1,n) cin>>a[i].second;

    sort(a+1,a+n+1,cmp);

    FOR(i,1,n) update(1,1,n,i,a[i].first);

    bool flag = true;
    ll swaps = 0;

    RFOR(i,1,n){
        
        while(1){
            auto val = query_max(1,1,n,1,i);
            if(val.first <= a[i].second){
                break;
            }else {
                auto min_in_right = query_min(1,1,n,i+1,n);
                auto max_in_left = query_max(1,1,n,1,i);

                if(min_in_right.first >= max_in_left.first){
                    flag = false;
                    break;
                }else {
                    swap(a[max_in_left.second].first,a[min_in_right.second].first);
                    swaps++;
                    
                    if(swaps > n-2){
                        flag = false;
                        break;
                    }

                    update(1,1,n,max_in_left.second,a[max_in_left.second].first);
                    update(1,1,n,min_in_right.second,a[min_in_right.second].first);
                }
            }
        }

        if(!flag) break;
    }

    if(flag) cout<<"Yes\n";
    else cout<<"No\n";
}

signed main(){

   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 14080