#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int> A(N), B(N);
    for (int &a: A)
        cin>>a;
    for (int &b: B)
        cin>>b;

    vector<pair<int,int>> T;
    for (int i=0; i<N; i++)
        T.push_back(make_pair(B[i], A[i]));
    sort(T.begin(), T.end());
    for (int i=0; i<N; i++)
        A[i] = T[i].second,
        B[i] = T[i].first;

    vector<int> I(N);
    for (int i=0; i<N; i++)
        I[i] = i;
    sort(I.begin(), I.end(), [&](int a, int b){return A[a]<A[b];});

    int c = 1;
    int p = I[0];
    while (p!=0)
    {
        p = I[p];
        c++;
    }

    bool ok = true;
    for (int i=0; i<N; i++)
        if (A[I[i]]>B[i])
            ok = false;
    if (!ok)
    {
        cout<<"No"<<endl;
        return 0;
    }

    if (c<N)
    {
        cout<<"Yes"<<endl;
        return 0;
    }

    for (int i=0; i<N-1; i++)
        if (A[I[i+1]]<=B[i] && A[I[i]]<=B[i+1])
        {
            cout<<"Yes"<<endl;
            return 0;
        }

    cout<<"No"<<endl;
}
