#include <bits/stdc++.h>
using namespace std;
const long long N = 1.1e5;
long long n;
pair<long long, long long> input[N];
vector<long long> a, b;
long long s[N], p[N];
bool cansort() {
  set<long long> st(a.begin(), a.end());
  if ((long long)st.size() < n) {
    return true;
  }
  copy_n(a.begin(), n, s);
  sort(s, s + n);
  for (long long i = 0; i < n; ++i) {
    p[i] = lower_bound(s, s + n, a[i]) - s;
  }
  set<long long> used;
  long long v = 0;
  for (long long it = 0; it < n; ++it) {
    used.insert(v);
    v = p[v];
  }
  return (long long)used.size() < n;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a.resize(n);
  b.resize(n);
  for (long long i = 0; i < n; ++i) {
    cin >> input[i].second;
  }
  for (long long i = 0; i < n; ++i) {
    cin >> input[i].first;
  }
  sort(input, input + n);
  for (long long i = 0; i < n; ++i) {
    tie(b[i], a[i]) = input[i];
  }
  long long ind = -1;
  for (long long i = 0; i < n; ++i) {
    if (a[i] > b[i]) {
      continue;
    }
    if (ind == -1 || b[ind] > b[i]) {
      ind = i;
    }
  }
  if (!cansort()) {
    if (ind == -1) {
      cout << "No\n";
      return 0;
    }
    a.erase(a.begin() + ind);
    b.erase(b.begin() + ind);
    --n;
  }
  sort(a.begin(), a.end());
  assert(is_sorted(b.begin(), b.end()));
  for (long long i = 0; i < n; ++i) {
    if (a[i] > b[i]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
