#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;


// 根が1 !!!!!
template<typename Monoid>
struct segtree {
    using T = typename Monoid::T;
    int n;
    vector<T> dat;

    segtree(int n_) {
        n = 1;
        while(n < n_) n <<= 1;
        dat.assign(n*2, Monoid::id());
    }
    void build(vector<T> v) {
        REP(i, v.size()) dat[i+n] = v[i];
        for(int i=n-1; i>0; --i) dat[i] = Monoid::op(dat[i*2], dat[i*2+1]);
    }

    T query(int a, int b) {
        T l = Monoid::id(), r = Monoid::id();
        for(a+=n, b+=n; a<b; a>>=1, b>>=1) {
            if(a&1) l = Monoid::op(l, dat[a++]);
            if(b&1) r = Monoid::op(dat[--b], r);
        }
        return Monoid::op(l, r);
    }
    void update(int i, T v) {
        i += n;
        dat[i] = v;
        while(i >>= 1) {
            dat[i] = Monoid::op(dat[i*2], dat[i*2+1]);
        }
    }

    friend ostream &operator <<(ostream& out,const segtree<Monoid>& seg){
        out << "---------------------" << endl;
        int cnt = 1;
        for(int i=1; i<=seg.n; i*=2) {
            REP(j, i) {
                out << seg.dat[cnt] << " ";
                cnt++;
            }
            out << endl;
        }
        out << "---------------------" << endl;
        return out;
    }
};

template<typename Tp>
struct min_monoid {
    using T = Tp;
    static constexpr Tp id() { return PII(INF, INF); }
    static Tp op(const Tp &a, const Tp &b) { return min(a, b); }
};

int main(void) {
    ll n;
    cin >> n;
    vector<PII> p(n);
    REP(i, n) cin >> p[i].second;
    REP(i, n) cin >> p[i].first;
    sort(ALL(p));    

    map<PII,ll> pos;
    vector<ll> a(n), b(n);
    REP(i, n) {
        a[i] = p[i].second;
        b[i] = p[i].first;
        pos[PII(a[i],i)] = i;
    }

    multiset<PII> st;
    REP(i, n) st.insert(PII(a[i], i));

    // for(auto i: st) cerr << i.first << "," << i.second << " ";
    // cerr << endl;

    segtree<min_monoid<PII>> seg(n);
    vector<PII> init(n);
    REP(i, n) init[i] = PII(a[i], i);
    seg.build(init);

    // dump(a);
    // dump(b);
    // dump(as);
    
    ll cnt = 0;
    while(st.size()) {
        ll idx1 = st.rbegin()->second;
        ll val1 = seg.query(idx1, idx1+1).first;
        if(seg.query(idx1, idx1+1).first <= b[idx1]) {
            st.erase(st.find(PII(val1, idx1)));
            continue;
        }

        cnt++;
        ll x = lower_bound(ALL(b), val1) - b.begin();
        if(x == n) {
            cout << "No" << endl;
            return 0;
        }
        PII ret = seg.query(x, n);

        ll idx2 = ret.second;
        ll val2 = ret.first;

        dump(idx1, val1, idx2, val2);
        seg.update(idx1, PII(val2, idx1));
        seg.update(idx2, PII(val1, idx2));

        // for(auto i: st) cerr << i.first << "," << i.second << " ";
        // cerr << endl;
        
        st.erase(st.find(PII(val1, idx1)));
        st.erase(st.find(PII(val2, idx2)));
        st.insert(PII(val2, idx1));
        // {
        //     auto sst(st);
        //     for(auto i: sst) cerr << i.first << "," << i.second << " ";
        //     cerr << endl;
        // }
    }

    // dump(seg);
    // dump(b);
    // dump(cnt);

    bool flag = true;
    REP(i, n) if(seg.query(i, i+1).first > b[i]) flag = false;
    if(cnt > n-2) flag = false;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 23040