#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <array>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>

/* ----- Type Alias ----- */
using lint = long long int;
using ldouble = long double;
template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T>
T ndvec(T v) { return v; }

template <class T, class... Ts>
auto ndvec(size_t l, Ts... ts) {
    return std::vector<decltype(ndvec<T>(ts...))>(l, ndvec<T>(ts...));
}

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;
template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    int precision;
    explicit Fout(int precision) : precision(precision) {}
};

std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}

/* ----- Constants ----- */
// constexpr int INF = std::numeric_limits<int>::max() / 3;
// constexpr int MOD = 1000000007;
// const Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

void fail() {
    std::cout << "No" << std::endl;
    std::exit(0);
}

void success() {
    std::cout << "Yes" << std::endl;
    std::exit(0);
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> a(n), b(n);
    for (auto& x : a) std::cin >> x;
    for (auto& x : b) std::cin >> x;

    {
        std::vector<int> idx(n);
        std::iota(idx.begin(), idx.end(), 0);

        std::sort(idx.begin(), idx.end(),
                  [&](int i, int j) { return b[i] < b[j]; });

        std::vector<int> na(n), nb(n);
        for (int i = 0; i < n; ++i) {
            na[i] = a[idx[i]];
            nb[i] = b[idx[i]];
        }

        a = na, b = nb;
    }

    auto sa = a;
    std::sort(sa.begin(), sa.end());

    for (int i = 0; i < n; ++i) {
        if (sa[i] > b[i]) fail();
    }

    for (int i = 0; i + 1 < n; ++i) {
        if (sa[i + 1] <= b[i]) success();
    }

    std::vector<int> pos(n);
    {
        auto reva = compress(sa);
        for (int i = 0; i < n; ++i) {
            a[i] = reva[a[i]];
            pos[a[i]] = i;
        }
    }

    for (int i = 0; i < n - 1; ++i) {
        if (a[i] == i) success();
        int j = pos[i];
        pos[i] = i;
        pos[a[i]] = j;
        std::swap(a[i], a[j]);
    }

    fail();
    return 0;
}


Measured memory_bytes: 6504