#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  vector<pair<int, int>> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i].first;
    b[i].second = i;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < a.size(); i++) {
    if (a[i].first > b[i].first) {
      cout << "No";
      return 0;
    }
  }
  for (int i = 0; i < a.size() - 1; i++) {
    if (a[i+1].first <= b[i].first) {
      cout << "Yes";
      return 0;
    }
  }
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    p[a[i].second] = b[i].second;
  }
  int cur = p[0];
  int len = 1;
  while (cur != 0) {
    len++;
    cur = p[cur];
  }
  if (len < n) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}