#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  pair<int, int> aa[n], ar[n], br[n];
  int ga[n], gb[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i].first;
    ar[i].second = i;
    aa[i].first = ar[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> br[i].first;
    br[i].second = i;
    aa[i].second = br[i].first;
  }
  sort(ar, ar + n);
  sort(br, br + n);
  for (int i = 0; i < n; i++) {
    if (ar[i].first > br[i].first) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i && br[i - 1].first >= ar[i].first) {
      cout << "Yes\n";
      return 0;
    }
    ga[ar[i].second] = i;
    gb[br[i].second] = i;
  }
  set<pair<int, int>> sp;
  for (int i = 0; i < n; i++) {
    if (ga[i] == gb[i] || (sp.count(make_pair(gb[i], ga[i])))) {
      cout << "Yes\n";
      return 0;
    }
    sp.insert(make_pair(ga[i], gb[i]));
  }
  cout << "No\n";
}
