#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
 
const int maxN = 1 << 19;

pair <int, int> A[maxN], B[maxN];
int p[maxN];

void ans(bool ok)
{
	printf("%s\n", ok ? "Yes" : "No");
	exit(0);
}

void solve()
{
	int n;
	scanf ("%d", &n);
	FOR(i, 0, n)
		scanf ("%d", &A[i].st), A[i].nd = i;
	FOR(i, 0, n)
		scanf ("%d", &B[i].st), B[i].nd = i;
	
	sort(A, A+n);
	sort(B, B+n);
	FOR(i, 0, n)
		if (A[i].st > B[i].st)
			ans(false);
	FOR(i, 1, n)
		if (A[i].st <= B[i-1].st)
			ans(true);
			
	FOR(i, 0, n)
		p[A[i].nd] = B[i].nd;

	int len = 0, v = 0;
	do
	{
		len++;
		v = p[v];
	}
	while (v != 0);
	ans(len != n);
}
 
int main()
{
	int t;
	t = 1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}

