#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
int MAX_V = 500000;
vvi G = vv(MAX_V, 0, 0, int);
vvi rG = vv(MAX_V, 0, 0, int);
vector<bool> used(MAX_V);
vector<int> cmp(MAX_V);
vector<int> vs;

void add_edge(int from, int to){ G[from].push_back(to), rG[to].push_back(from);}
void dfs(int v){
  used[v] = true;
  for(int i=0;i<G[v].size();i++) if(!used[G[v][i]]) dfs(G[v][i]);
  vs.push_back(v);
}
void rdfs(int v, int k){
  used[v] = true;
  cmp[v] = k;
  for(int i=0;i<rG[v].size();i++) if(!used[rG[v][i]]) rdfs(rG[v][i], k);
}
int scc(int V){
  for(int i=0;i<MAX_V;i++) used[i] = false;
  vs.clear();
  for(int i=0;i<=V;i++) if(!used[i]) dfs(i);
  for(int i=0;i<MAX_V;i++) used[i] = false;
  int k = 0;
  for(int i=vs.size()-1;i>=0;i--) if(!used[vs[i]]) rdfs(vs[i], k++);
  return k;
}
//-------------------------------------------------------------------
#include <sstream>
#include <fstream>
ifstream ifs;
void init(string s){ifs.open(s);}
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while(getline(ss, buffer, sep)) v.push_back(buffer);
    return v;
}
ll read(){
  string str;
  getline(ifs, str);
  return stoll(str);
}
string read_str(){
  string str;
  getline(ifs, str);
  return str;
}
vector<ll> read_vec(){
  string str;
  getline(ifs, str);
  std::vector<ll> num;
  vector<string> data = split(str, ' ');
  for(int i=0;i<data.size();i++) num.push_back(stoll(data[i]));
  return num;
}
vvl read_mat(ll h){
  string str;
  vvl num = vv(h, 0, 0, ll);
  for(int i=0;i<h;i++){
    getline(ifs, str);
    vector<string> data = split(str, ' ');
    for(int j=0;j<data.size();j++) num[i].push_back(stoll(data[j]));
  }
  return num;
}
//-------------------------------------------------------------------

//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  //init("29.in");
  ll n;
  std::cin >> n;
  //n = read();
  std::vector<ll> A(n), B(n);
  vvl a = vv(n, 2, 0, ll);
  vvl b = vv(n, 2, 0, ll);
  //A = read_vec();
  //B = read_vec();
  for(int i=0;i<n;i++){
    std::cin >> a[i][0];
    //a[i][0] = A[i];
    a[i][1] = i;
  }
  for(int i=0;i<n;i++){
    std::cin >> b[i][0];
    //b[i][0] = B[i];
    b[i][1] = i;
  }
  //for(int i=0;i<n;i++)std::cin >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for(int i=0;i<n;i++){
    if(a[i][0]>b[i][0]){
      std::cout << "No" << '\n';
      return 0;
    }
  }

  for(int i=0;i<n;i++){
    add_edge(a[i][1], b[i][1]);
    add_edge(b[i][1], a[i][1]);
  }
  scc(n+3);
  set<int> num;
  for(int i=0;i<n;i++) num.insert(cmp[i]);
  //std::cout << num.size() << '\n';
  if(num.size()>=2){
    std::cout << "Yes" << '\n';
    return 0;
  }
  for(int i=0;i<n-1;i++) {
    if(a[i+1][0]<=b[i][0]){
      std::cout << "Yes" << '\n';
      return 0;
    }
  }
  std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 49792