#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  for(int&x:a) cin >> x;
  for(int&x:b) cin >> x;
  vector<int> sa(a),sb(b);
  sort(sa.begin(),sa.end());
  sort(sb.begin(),sb.end());
  vector<pair<int,int>> sba(n);
  REP(i,n) sba[i] = make_pair(b[i],a[i]);
  sort(sba.begin(),sba.end());
  REP(i,n) a[i] = sba[i].second;
  REP(i,n) {
    if(sa[i] > sb[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  FOR(i,1,n) {
    if(sa[i] <= sb[i-1]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  map<int,int> ma;
  REP(i,n) ma[sa[i]] = i;
  int ind = 0;
  int loop = 0;
  do {
    ind = ma[a[ind]];
    ++loop;
  } while(ind);
  if(loop == n) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}
