// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

#define maxn 100010

#define mod 1000000007

struct cv{

    int x,y;

}a[maxn];

int b[maxn];

int cnt;

set<int>s[maxn];

int dp[maxn],du[maxn];

bool cmp(cv p,cv q){

    if(p.x!=q.x) return p.x<q.x;

    return p.y<q.y;

}

int main(){

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++) scanf("%d",&a[i].x);

    for(int i=0;i<n;i++) scanf("%d",&a[i].y),b[i]=a[i].y;

    sort(a,a+n,cmp);

    sort(b,b+n);

    cnt=0;

    int flag=0;

    for(int i=0;i<n;i++){

        if(a[i].x>b[i]){

            printf("No\n");

            return 0;

        }

        if(i<n-1&&a[i+1].x<b[i]) flag=1;

        if(i!=0){

            if(b[i]==b[i-1]) flag=1;

        }

        if(i!=0&&a[i].x!=a[i-1].x){

            cnt++;

            s[cnt].insert(a[i].y);

        }

        else{

            s[cnt].insert(a[i].y);

            if(i!=0) flag=1;

        }

    }

    cnt=0;

    if(flag){

        printf("Yes\n");

        return 0;

    }

    for(int i=0;i<n;i++){

        dp[lower_bound(b,b+n,a[i].y)-b]=i;

    }

    cnt=0;

    for(int i=0;i<n;i++){

        if(du[i]) continue;

        cnt++;

        du[i]=1;

        int x=dp[i];

        while(du[x]==0){

            du[x]=1;

            x=dp[x];

        }

    }

    if(cnt>=2) printf("Yes\n");

    else printf("No\n");

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7786984387616143x):
#include <bits/stdc++.h>



using namespace std;



template<class T, class U>

void ckmin(T &a, U b)

{

    if (a > b) a = b;

}



template<class T, class U>

void ckmax(T &a, U b)

{

    if (a < b) a = b;

}



#define MP make_pair

#define PB push_back

#define LB lower_bound

#define UB upper_bound

#define fi first

#define se second

#define SZ(x) ((int) (x).size())

#define ALL(x) (x).begin(), (x).end()

#define FOR(i, a, b) for (auto i = (a); i < (b); i++)

#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

#define MAXN 100013

#define INF 1000000007



typedef long long ll;

typedef long double ld;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef vector<pii> vpi;

typedef vector<pll> vpl;



int N;

pii arr[MAXN];

int val[MAXN];

vi guys[MAXN];

bitset<MAXN> vis;



int32_t main()

{

    cout << fixed << setprecision(12);

    cerr << fixed << setprecision(4);

    ios_base::sync_with_stdio(false); cin.tie(0);

    cin >> N;

    FOR(i, 0, N)

    {

        cin >> arr[i].se; arr[i].se = -arr[i].se;

    }

    FOR(i, 0, N)

    {

        cin >> arr[i].fi; arr[i].fi = -arr[i].fi;

    }

    sort(arr, arr + N);

    //ai.se >= bi.se

    FOR(i, 0, N)

    {

        val[i] = UB(arr, arr + N, MP(arr[i].se, INF)) - arr - 1;

        if (val[i] < 0)

        {

            cout << "No\n";

            return 0;

        }

        guys[val[i]].PB(i);

    }

    int tot = 0;

    FOR(i, 0, N)

    {

        tot += SZ(guys[i]);

        if (tot > i + 1)

        {

            cout << "No\n";

            return 0;

        }

    }

    FOR(i, 0, N)

    {

        if (guys[i].empty())

        {

            cout << "Yes\n";

            return 0;

        }

    }

    int u = 0;

    FOR(i, 0, N)

    {

        vis[u] = true;

        u = guys[u][0];

    }

    FOR(i, 0, N)

    {

        if (!vis[i])

        {

            cout << "Yes\n";

            return 0;

        }

    }

    cout << "No\n";

    return 0;

    //i can go to [0...val[i]].

    //if there's only one guy that can go to 0, we assign it.

    //you can permute the arr[i].se in any order that's not a cycle. can you get all ai < bi?

}