#include <bits/stdc++.h>

using namespace std;

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	
	int a[n];
	int b[n];
	
	int x[n];
	int y[n];
	
	map<int,int> fw;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		x[i] = a[i];
	}
	
	for(int i = 0;i < n;i++){
		cin >> b[i];
		y[i] = b[i];
		fw[a[i]] = b[i];
	}
	
	sort(x,x+n);
	sort(y,y+n);

	
	map<int,int> nxt;
	for(int i = 0;i < n;i++){
		if(x[i] > y[i]){
			cout << "No";
			return 0;
		}
		nxt[y[i]] = x[i];
	}
	
	for(int i = 0;i < n;i++){
		if(i != 0 && x[i] <= y[i-1]){
			cout << "Yes";
			return 0;
		}
	}
	

	
	int u = a[0];
	set<int> vis;
	while(true){
		//cout << u << "\n";
		if(vis.find(u) != vis.end()) break;
		vis.insert(u);
		u = nxt[fw[u]];
	}
	
	if(vis.size() != n){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}
