#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
#define mini(a, b) a = min(a, b)
#define maxi(a, b) a = max(a, b)

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

const int MAXN = 5e5 + 10;

const long long mod = 998244353;
int n;
int a[MAXN], b[MAXN];
pii ab[MAXN];


bool good() {
	// for(int i = 0;i < n ;) {
	// 	int j;
	// 	for(j = i; ab[j].second == ab[i].second; j++);
	// 	random_shuffle(ab + i, ab + j);
	// 	i = j;
	// }
    vector<int>order(n), vis(n);
    iota(all(order), 0);

    sort(all(order), [&](const int & x, const int & y) {
    	return ab[x].first < ab[y].first;
    });

    int cnt1 = 0, cnt2 = 0;
    for(int i = 0; i < n; i++) {
    	if(order[i] != i) {
    		cnt1++;
    		while(order[i] != i) {
    			vis[order[i]] = 1;
    			swap(order[i], order[order[i]]);
    		}
    		vis[i] = 1;
    	}
    	else if(!vis[i])
    		cnt2++;
    }
    debug << "count is" << cnt1 << cnt2 << endl;
    return cnt1 >= 2 || cnt2 >= 1;
}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    cin >> n;
    
    for(int i = 0; i < n; i++) {
    	cin >> a[i];
    	ab[i].first = a[i];
    }
    for(int i = 0; i < n; i++) {
    	cin >> b[i];
    	ab[i].second = b[i];
    }

    sort(a, a + n);
    sort(b, b + n);
    int valid = 1;
    for(int i = 0; i < n; i++)
    	if(a[i] > b[i])
    		valid = 0;
    if(!valid) {
    	cout << "No" << endl;
    	return 0;
    }

    valid = 0;
    for(int i = 1; i < n; i++)
    	if(a[i] <= b[i - 1])
    		valid = 1;
    if(valid) {
    	cout << "Yes" << endl;
    	return 0;
    }

    sort(ab, ab + n, [](const pii & x, const pii & y) {
    	return x.second < y.second || (x.second == y.second && x.first < y.first);
    });

    valid = good();
    if(!valid) {
    	cout << "No" << endl;
    }
    else cout << "Yes" << endl;

    return 0;
 
}














Measured memory_bytes: 6016