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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

class UnionFind{
private:
  ::std::vector<int_fast32_t> par;
  size_t n;

public:
  UnionFind(){}
  UnionFind(size_t n):n(n){
    par.resize(n, -1);
  }

  uint_fast32_t find(uint_fast32_t x){
    return par[x] < 0 ? x : par[x] = find(par[x]);
  }

  size_t size(uint_fast32_t x){
    return -par[find(x)];
  }

  bool unite(uint_fast32_t x, uint_fast32_t y){
    x = find(x);
    y = find(y);
    if(x == y) return false;
    if(size(x) < size(y)) std::swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  bool same(uint_fast32_t x, uint_fast32_t y){
    return find(x) == find(y);
  }
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<int64> A(N), B(N);
	vector<PLL> ab(N);
	REP(i, N) cin >> A[i];
	REP(i, N) cin >> B[i];
	vector<int64> Ac(A), Bc(B);
	sort(all(Ac), greater<int64>()); sort(all(Bc), greater<int64>());
	multiset<PLL> st;
	REP(i, N) {
	  if (Ac[i] > Bc[i]) {
	    cout << "No" << endl;
	    return 0;
	  }
//	  ab[i] = PLL(A[i], -i-1);
//	  ab[i] = PLL(B[i], i+1);
    ab[i] = PLL(B[i], i);
	  st.emplace(A[i], i);
	}
	sort(all(ab), greater<PLL>());
	int64 left;
	vector<int> used(N, 0);
	int64 cnt = 0;
	REP(i, N) {
	  if (used[ab[i].sc]) continue;
	  used[ab[i].sc] = 1;
	  left = A[ab[i].sc];
	  int64 right = ab[i].fs, idx = ab[i].sc;
	  while (1) {
//	    cout << left << " " << idx << " " << right << endl;
	    auto itr = st.upper_bound(PLL(right, INF_LL));
	    if (itr == st.begin()) {
	      cout << "No" << endl;
	      return 0;
	    }
	    itr = prev(itr);
//	    cout << itr->fs << " " << itr->sc << endl;
	    if (itr->fs == left) {
	      st.erase(PLL(left, ab[i].fs));
	      break;
	    } else {
	      idx = itr->sc;
	      right = B[idx];
	      st.erase(itr);
	      used[idx] = 1;
	    }
	  }
	  cnt++;
	}
  if (cnt == 1) {
    cout << "No" << endl;
  }	else {
    cout << "Yes" << endl;
  }

//	UnionFind uf(N+1);
//
//	sort(all(ab), greater<PLL>());
//	int64 sum = 0;
//	int64 rest = -1;
//  REP(i, 2*N) {
//    int64 val, tp;
//    tie(val, tp) = ab[i];
//    if (tp < 0) {
//      if (sum == 0) {
//        cout << "No" << endl;
//        return 0;
//      } else {
//        uf.unite(-tp, rest);
//        rest = -1;
//      }
//    } else {
//      sum++;
//      if (sum >= 2) {
//        cout << "Yes" << endl;
//        return 0;
//      }
//      rest = tp;
//    }
//  }
//  if (uf.size(1) == N) {
//    cout << "No" << endl;
//    return 0;
//  } else {
//    cout << "Yes" << endl;
//  }
}


Measured memory_bytes: 11520