#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int N, A[1 << 18], R[1 << 18];
pair<int, int> T[1 << 18];
map<int, int> Map;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> T[i].second;
	for (int i = 0; i < N; i++) cin >> T[i].first;
	sort(T, T + N);
	for (int i = 0; i < N; i++) A[i] = T[i].second;
	sort(A, A + N);

	// ステップ 1.
	for (int i = 0; i < N; i++) {
		if (A[i] > T[i].first) { cout << "No" << endl; return 0; }
	}

	// ステップ 2.
	for (int i = 0; i < N - 1; i++) {
		swap(A[i], A[i + 1]); bool flag = false;
		if (A[i] > T[i].first) flag = true;
		if (A[i + 1] > T[i + 1].first) flag = true;
		if (flag == false) { cout << "Yes" << endl; return 0; }
		swap(A[i], A[i + 1]);
	}

	// ステップ 3.
	for (int i = 0; i < N; i++) {
		int pos1 = lower_bound(A, A + N, T[i].second) - A;
		pos1 += Map[A[i]];
		R[i] = pos1; Map[A[i]]++;
	}

	int cnt = 0, cx = 0;
	while (true) {
		cx = R[cx]; cnt++;
		if (cx == 0) break;
	}
	if (cnt != N) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}