/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iterator>
#include <random>
#include <cassert>
#include <iomanip>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<char> vc;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;
typedef vector<vector<char>> vcc;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}
const double EPS = 1e-10;
const double PI = acos(-1);

class UnionFind{
private:
    int n, m;
    vector<int> parent, r;

    int _find(int x){
        if(parent[x] == x) return x;
        else return parent[x] = _find(parent[x]);
    }

    void _unite(int x, int y){
        x = _find(x); y = _find(y);
        if(x == y) return;
        --m;
        if(r[x]<r[y]){
            parent[x] = y;
            r[y] += r[x];
        }
        else{
            parent[y] = x;
            r[x] += r[y];
        }
    }

public:
    int find(int x){
        return _find(x);
    }

    void unite(int x, int y){
        return _unite(x, y);
    }

    int size(int x){
        return r[_find(x)];
    }

    int count(){
        return m;
    }

    int operator[](int i){
        return find(i);
    }

    UnionFind() : n(0), m(0){}

    explicit UnionFind(size_t _n) : n(_n), m(_n){
        parent = vector<int>(n);
        r = vector<int>(n);
        for(int i=0;i<n;i++){
            parent[i] = i;
            r[i] = 1;
        }
    }
};

bool cmp(pii p1, pii p2){
    return p1.second < p2.second;
}

class CSwaps {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vector<pii> A(N), P(N);
        REP(i, N) in>>A[i].first;
        REP(i, N) in>>A[i].second;
        sort(ALL(A), cmp);
        REP(i, N) P[i].first = A[i].first, P[i].second = i;
        sort(ALL(P));
        UnionFind uf(N);
        REP(i, N){
            uf.unite(P[i].second, i);
            if(P[i].first>A[i].second){
                out<<"No\n";
                return;
            }
        }
        if(uf.count()>1){
            out<<"Yes\n";
            return;
        }
        REP(i, N-1){
            if(P[i+1].first<=A[i].second){
                out<<"Yes\n";
                return;
            }
        }
        out<<"No\n";
    }
};


int main() {
	CSwaps solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2560