/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;
int x[N], y[N], nxt[N];
int n, a[N], b[N];
bool mark[N];

inline void read_input() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[x[i] = i];
	for (int i = 0; i < n; i++)
		cin >> b[y[i] = i];
}

inline void solve() {
	sort(x, x + n, [] (int i, int j) {
		return a[i] < a[j];
	});
	sort(y, y + n, [] (int i, int j) {
		return b[i] < b[j];
	});
	sort(a, a + n);
	sort(b, b + n);
}

inline void write_output() {
	bool ok = false;
	for (int i = 0, p = 0; i < n; i++) {
		while (p < n && b[i] >= a[p])
			p++;
		if (p <= i) {
			cout << "No";
			return;
		}
		ok |= p > i + 1, nxt[x[i]] = y[i];
	}
	if (ok) {
		cout << "Yes";
		return;
	}
	for (int i = 0; !mark[i]; i = nxt[i])
		mark[i] = true;
	for (int i = 0; i < n; i++)
		if (!mark[i]) {
			cout << "Yes";
			return;
		}
	cout << "No";
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	read_input(), solve(), write_output();
	return 0;
}
