#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1e5+5;
struct rec{
	int x,y;
	bool operator < (const rec& b) const{
		return x<b.x;
	}
} a[MAXN],b[MAXN];
int n,fa[MAXN];
int find(int x){ return fa[x]==x?x:fa[x]=find(fa[x]); }
void uion(int x,int y){ fa[find(x)]=find(y); }
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i].x),a[i].y=i;
	for (int i=1;i<=n;i++) scanf("%d",&b[i].x),b[i].y=i;
	sort(a+1,a+n+1); sort(b+1,b+n+1); 
	bool fl=0;
	for (int i=1;i<=n;i++){
		if (a[i].x>b[i].x) fl=1;
	}
	if (fl) return printf("No\n"),0;
	for (int i=1;i<n;i++){
		if (a[i+1].x<=b[i].x) fl=1;
	}
	for (int i=1;i<=n;i++) fa[i]=i;
	for (int i=1;i<=n;i++){
		uion(a[i].y,b[i].y);
	}
	int top=find(1);
	for (int i=2;i<=n;i++){
		int tmp=find(i);
		if (tmp!=top) fl=1;
	}
	if (fl) printf("Yes\n");
	else printf("No\n");
	return 0;
}
