import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

int[] ra (size_t n) {
  auto a = new int[n];
  foreach (i; 0 .. n) {
    readf (" %d", &a[i]);
  }
  return a;
}

void sorting (int[] a, int[] b) {
  auto n = a.length;
  auto c = a.dup;
  auto d = b.dup;
  auto idx = new size_t[n];
  makeIndex (d, idx);
  foreach (i; 0 .. n) {
    a[i] = c[idx[i]];
    b[i] = d[idx[i]];
  }
}

bool sorting_test (in int[] a, in int[] b) {
  auto c = a.dup;
  sort (c);
  if (iota (0, a.length).any! (i => c[i] > b[i])) {
    return false;
  }
  return true;
}

bool test () {
  size_t n;
  readf (" %d", &n);
  auto a = ra (n);
  auto b = ra (n);
  debug stderr.writeln ("a = ", a);
  debug stderr.writeln ("b = ", b);
  sorting (a, b);
  debug stderr.writeln ("a = ", a);
  debug stderr.writeln ("b = ", b);
  if (!sorting_test (a, b)) {
    return false;
  }
  auto idx = new size_t[n];
  makeIndex (a, idx);
  foreach (i; 1 .. n) {
    if (a[idx[i-1]] == a[idx[i]]) {
      return true;
    }
  }
  if (iota (0, n).any! (i => idx[i] == i)) {
    return true;
  }
  if (iota (0, n).any! (i => idx[idx[i]] == i)) {
    return true;
  }
  return false;
  /*
  auto d = new int[n];
  foreach (i; 0 .. n) {
    d[i] = a[idx[i]];
  }
  auto c = a.dup;
  int swaps;
  foreach (i; 0 .. n) {
    if (d[i] != c[i]) {
      swap (
    }
  }
  */
  /*
  sort (a);
  debug stderr.writeln ("a = ", a);
  debug stderr.writeln ("b = ", b);
  if (iota (0, n).any! (i => a[i] > b[i])) {
    return false;
  }
  return (iota (1, n).any! (i => a[i] <= b[i-1]));
  */
  /*
  auto c = a.dup;
  sort (c);
  debug stderr.writeln ("b = ", b);
  debug stderr.writeln ("c = ", c);
  if (iota (0, n).any! (i => c[i] > b[i])) {
    return false;
  }
  */
  //return false;
  //return true;
}

void main() {
  writeln (test () ? "Yes" : "No");
}

