#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    vector<int> x(n), y(n);
    iota(x.begin(), x.end(), 0);
    sort(x.begin(), x.end(), [&](int i, int j) { return a[i] < a[j]; });
    iota(y.begin(), y.end(), 0);
    sort(y.begin(), y.end(), [&](int i, int j) { return b[i] < b[j]; });
    bool unique = true;
    for (int i = 0; i < n; i++) {
        if (a[x[i]] > b[y[i]]) { cout << "No\n" << endl; return 0; }
        if (i > 0 && a[x[i]] <= b[y[i - 1]]) unique = false;
    }
    if (unique) {
        vector<int> p(n);
        for (int i = 0; i < n; i++) p[y[i]] = x[i];
        int c = 1, i = p[0];
        while (i != 0) {
            i = p[i]; c++;
        }
		cout << (c < n ? "Yes\n" : "No\n");
    } else {
        cout << "Yes\n";
    }
}