#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
using namespace std;
const int N=100005;
int n,a[N],b[N];
int ida[N],idb[N];
int p[N],vis[N];
bool cmpa(int x,int y){
	return a[x]<a[y];
}
bool cmpb(int x,int y){
	return b[x]<b[y];
}
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	For(i,1,n) scanf("%d",&b[i]);
	For(i,1,n) ida[i]=idb[i]=i;
	sort(ida+1,ida+n+1,cmpa);
	sort(idb+1,idb+n+1,cmpb);
	For(i,1,n)
		if (a[ida[i]]>b[idb[i]])
			return puts("No"),0;
	For(i,1,n) p[idb[i]]=ida[i];
	for (int x=1;!vis[x];vis[x]=1,x=p[x]);
	For(i,1,n) if (!vis[i])
		return puts("Yes"),0;
	For(i,1,n-1) if (a[ida[i+1]]<=b[idb[i]])
		return puts("Yes"),0;
	puts("No");
}