#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef pair<int, int> pii;
#define F first
#define S second
pii p[maxn];
int c[maxn], d[maxn];
int id[maxn];
int r[maxn];
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &p[i].F), c[i] = p[i].F;
	for(int i = 0; i < n; i++) scanf("%d", &p[i].S), d[i] = p[i].S;
	sort(c, c + n);
	sort(d, d + n);
	for(int i = 0; i < n; i++) {
		if(c[i] > d[i]) return puts("No"), 0;
	}
	for(int i = 0; i < n; i++) {
		if(i && c[i] <= d[i - 1]) return puts("Yes"), 0;
	}
	sort(p, p + n);
	for(int i = 0; i < n; i++) id[i] = lower_bound(d, d + n, p[i].S) - d;
	for(int i = 0; i < n; i++) r[id[i]] = i;
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		if(id[i] == i) continue;
		int j = r[i];
		int k = id[i];
		swap(r[i], r[k]);
		swap(id[i], id[j]);
		cnt++;
	}
	if(cnt <= n - 2) puts("Yes");
	else puts("No");
	return 0;
}

