#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 100005;
int n,a,p[MX],c;
bool f1=true,f2;
P as[2][MX];
int find(int x){return (p[x] < 0 ? x : p[x] = find(p[x]));}
void uni(int x, int y){
	x = find(x); y = find(y);
	if(x != y){
		if(p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
	}else c++;
}
int main(){
	scanf("%d", &n);
	rep(o,2){
		rep(i,n){
			scanf("%d", &a);
			as[o][i] = {a,i};
		}
		sort(as[o],as[o]+n);
	}
	rep(i,n){
		if(as[0][i].first>as[1][i].first) f1=false;
		if(i&&as[0][i].first<=as[1][i-1].first) f2=true;
	}
	fill(p, p+n, -1);
	rep(i,n) uni(as[0][i].second,as[1][i].second);
	puts(f1&&(f2||c>1) ? "Yes" : "No");
}