#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
// ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
string s,t;
int N,K;

vi A,B;
vpii datas;
struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if(x != y) {
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
}uf;
int main(){
	cin>>N;
	set<int> che,che2;
	rep(i,N){
		int x;
		cin>>x;
		A.pb(x);
		che.insert(x);
	}
	rep(i,N){
		int x;
		cin>>x;
		B.pb(x);
		che2.insert(x);
	}
	rep(i,N){
		datas.pb(mp(B[i],A[i]));
	}
	sort(all(A));
	sort(all(B));
	bool flag=true;
	rep(i,N)if(A[i]>B[i])flag=false;
	if(flag){
		int op=0;
		if(che.size()!=N||che2.size()!=N)cout<<"Yes"<<endl;
		else{
			rep(i,N-1){
				if(A[i+1]<=B[i]){
					cout<<"Yes"<<endl;
					return 0;
				}
			}

			map<int,int> AA,BB;
			rep(i,N)AA[A[i]]=i;
			rep(i,N)BB[B[i]]=i;
			uf.init(N);
			rep(i,N){
				int a=datas[i].second,b=datas[i].first;
				uf.unionSet(AA[a],BB[b]);
			}
			int cnt=0;
			rep(i,N)if(uf.root(i)==i)cnt++;
			//cout<<cnt<<endl;
			if(cnt==1){
				cout<<"No"<<endl;
			}else{
				cout<<"Yes"<<endl;
			}
		}
	}else{
		cout<<"No"<<endl;

	}

}





Measured memory_bytes: 20980