#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
ll n,x,len,p[N];
pair<ll,ll> a[N],b[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=0;i<n;i++)cin>>a[i].first,a[i].second=i;
    for(ll i=0;i<n;i++)cin>>b[i].first,b[i].second=i;
    sort(a,a+n);sort(b,b+n);
    for(ll i=0;i<n;i++)if(a[i].first>b[i].first)return cout<<"No" , 0;
    for(ll i=0;i<n-1;i++)if(a[i+1].first<=b[i].first)return cout<<"Yes" , 0;
    for(ll i=0;i<n;i++)p[a[i].second]=b[i].second;
    do{
        x=p[x];
        len++;
    }while(x);
    cout<<(len==n?"No":"Yes");
}