#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

const int N=100000;

int n,a[N+9],b[N+9],x[N+9],y[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i){
    scanf("%d",&a[i]);
	x[i]=a[i];
  }
  for (int i=1;i<=n;++i){
	scanf("%d",&b[i]);
	y[i]=b[i];
  }
}

int cnt[N+9],p[N+9],vis[N+9],ans;

void Get_ans(){
  sort(x+1,x+n+1);
  sort(y+1,y+n+1);
  for (int i=1;i<=n;++i)
	if (x[i]>y[i]) return;
  ans=1;
  for (int i=1;i<=n;++i){
	if (++cnt[a[i]=lower_bound(y+1,y+n+1,a[i])-y]==2) return;
	p[b[i]=lower_bound(y+1,y+n+1,b[i])-y]=i;
  }
  for (int i=1;i<=n;++i) a[i]=p[a[i]];
  for (int i=1;!vis[i];i=a[i]) vis[i]=1;
  for (int i=1;i<=n;++i)
	if (!vis[i]) return;
  ans=0;
}

void work(){
  Get_ans();
}

void outo(){
  puts(ans?"Yes":"No");
}

int main(){
  into();
  work();
  outo();
  return 0;
}