#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void Pr(bool f){
    cout << (f ? "Yes" : "No") << endl;
    exit(0);
}

// v1をソートし、v2を対応する位置に移動する
template<typename T, typename U>
void pairSort(vector<T>& v1, vector<U>& v2, bool rev = false) {
    int n = v1.size();
    vector<pair<T, U>> p(n);
    for(int i = 0; i < n; i++) {
        p[i] = pair<T, U>(v1[i], v2[i]);
    }
    if(rev) {
        sort(p.begin(), p.end(), [&](const auto& l, const auto& r) {
            if(l.first == r.first)
                return l.second > r.second;
            else return l.first < r.first;
        });
    } else {
        sort(p.begin(), p.end());
    }
    for(int i = 0; i < n; i++) {
        v1[i] = p[i].first;
        v2[i] = p[i].second;
    }
}

// ソートでどこに移動するかを得る
// 配列自体はソートされない
// {9, 5, 1, 3, 3} -> {4, 3, 0, 1, 2}
template<typename T>
vector<int> indexSort(const vector<T>& vec) {
    int n = vec.size();
    vector<pair<T, int>> p(n);
    for(int i = 0; i < n; i++) {
        p[i] = pair<T, int>(vec[i], i);
    }
    sort(p.begin(), p.end());
    vector<int> ret(n);
    for(int i = 0; i < n; i++) {
        ret[i] = lower_bound(p.begin(), p.end(), pair<T, int>(vec[i], i)) - p.begin();
    }
    return ret;
}

template<typename T> struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost): from(from), to(to), cost(cost) {}
    Edge(int from, int to): from(from), to(to), cost(1) {}
    bool operator<(Edge<T> &r) {
        return cost < r.cost;
    }
};
template<typename T>
ostream &operator<<(ostream &os, Edge<T> edge) {
    os << edge.from << " -> " << edge.to << " (" << edge.cost << ")";
    return os;
}

// グラフテンプレート(隣接リスト)
template<typename E = Edge<ll>> struct GraphL {
    // 頂点数、辺数
    int n, m;
    // 隣接リスト
    vector<vector<E>> adj;
    GraphL(int n)
        : n(n), m(0), adj(n), used(n, 0) {}
    
    template<typename... Args>
    void add_edge(int from, int to, Args... args) {
        adj[from].emplace_back(from, to, args...);
        m++;
    }
    
    vi used;
    ll dfs(ll s){
        ll ret = 1;
        used[s] = 1;
        for(auto&& e: adj[s]){
            if(!used[e.to]){
                ret += dfs(e.to);
            }
        }
        return ret;
    }
};
template<typename E = Edge<ll>>
ostream &operator<<(ostream &os, GraphL<E> graph) {
    os << "V = " << graph.n << ", E = " << graph.m << "\n";
    for(const auto& ev: graph.adj) {
        for(const auto& e: ev) {
            os << e << "\n";
        }
    }
    return os;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n), b(n);
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }
    vll sa(a), sb(b);
    sort(ALL(sa));
    sort(ALL(sb));
    rep(i, n){
        if(sa[i] > sb[i]){
            Pr(0);
        }
    }
    pairSort(b, a);
    vi idx = indexSort(a);
    dump(a);
    dump(b);
    dump(idx);
    GraphL<> g(n);
    rep(i, n){
        g.add_edge(i, idx[i]);
    }
    ll ring = g.dfs(0);
    if(ring == n){
        vll sc(n);
        rep(i, n){
            sc[i] = lower_bound(ALL(sb), sa[i])-sb.begin();
        }
        repr(i, 1, n){
            if(sc[i] == sc[i-1]){
                Pr(1);
            }
        }
        Pr(0);
    }else{
        Pr(1);
    }
    return 0;
}

Measured memory_bytes: 13032