#include <bits/stdc++.h>
using namespace std;
void swap(int &a, int &b) {
  int tmp = a;
  a = b;
  b = tmp;
}
int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) cin >> A[i].first;
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    A[i].second = B[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  for (int i = 0; i < N; i++) {
    if (A[i].first > B[i]) {
      cout << "No";
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if (i > 0 && A[i].first <= B[i - 1]) {
      goto OK;
    }
    if (i < N - 1 && A[i + 1].first <= B[i]) {
      goto OK;
    }
  }
  for (int i = 0; i < N; i++) {
    if (A[find(B.begin(), B.end(), A[i].second) - B.begin()].second == B[i]) {
      goto OK;
    }
  }
  cout << "No";
  return 0;
OK:
  cout << "Yes";
  return 0;
}
