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

#define N 100005

int a[N], b[N], nxt[N], n;

using pii = pair <int, int>;

vector <pii> A, B;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i]), A.push_back(pii(a[i], i));
	for (int i = 1; i <= n; i ++) scanf("%d", &b[i]), B.push_back(pii(b[i], i));
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	for (int i = 0; i < n; i ++) if (A[i].first > B[i].first) return puts("No"), 0;
	for (int i = 0; i < n; i ++) {
		if (i > 1 && A[i].first <= B[i-1].first) return puts("Yes"), 0;
	}
	for (int i = 0; i < n; i ++) nxt[A[i].second] = B[i].second;
	int now = 1, cnt = 0;
	do {
		cnt ++;
		now = nxt[now];
	} while (now != 1);
	if (cnt < n) puts("Yes");
	else puts("No");
	return 0;
}
