#include<bits/stdc++.h>
using namespace std;
int const nax = 1e5 + 10;
int n;
pair<int,int> a[nax], b[nax];
int p[nax];

int main(){
    scanf("%d", &n);
    for(int i = 1 ;i <= n ;i++){
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    for(int i = 1 ;i <= n; i++){
        scanf("%d", &b[i].first);
        b[i].second = i;
    }
    #define no return !printf("No");
    #define yes return !printf("Yes");
    sort(a + 1 , a + 1 + n);
    sort(b + 1 , b + 1 + n);
    for(int i = 1 ;i <= n ; i ++){
        if(a[i].first > b[i].first) no;
    }
    for(int i = 1 ;i <=  n ; i ++){
        if(i > 1 && a[i].first <= b[i-1].first)
            yes;
        p[a[i].second] = b[i].second;
    }
    int x = 1, it = 0;
    do{
        x = p[x];
        it ++;
    }while(x != 1);
    if(it == n)
        no
    else yes
    /// only one cycle -> answer is no
}
