#include <bits/stdc++.h>
using namespace std;
int par[int(0x7ffffff)];
int Rank[int(0x7ffffff)];
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    Rank[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (Rank[x] < Rank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (Rank[x] == Rank[y]) Rank[x]++;
  }
}
bool same(int x, int y) { return find(x) == find(y); }
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int N;
int A[100005], B[100005];
vector<pair<long long, long long> > Al, Bl;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    Al.push_back(pair<long long, long long>(a, i));
  }
  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    Bl.push_back(pair<long long, long long>(b, i));
  }
  sort(Al.begin(), Al.end());
  sort(Bl.begin(), Bl.end());
  int num = 0;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    if (Al[i].second == Bl[i].second) num++;
    if (Al[i].first > Bl[i].first) {
      cout << "No" << endl;
      return 0;
    }
    if (i < N - 1 && Bl[i].first >= Al[i + 1].first) {
      flag = true;
    }
  }
  if (num >= 2) {
    cout << "Yes" << endl;
    return 0;
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
