#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1e9+7;

int main() {
  int n;
  cin >> n;
  vector<pair<int, bool>> a(n*2);
  rep(i, n*2) {
    cin >> a[i].first;
    a[i].second = (i < n ? 1 : 0);
  }
  sort(a.begin(), a.end());
  int rem = (a[0].second ? 1 : -1);
  ll ans = 1;
  for (int i = 1; i < n*2; i++) {
    if (a[i].second) {
      if (rem >= 0)
        rem++;
      else {
        (ans *= -rem) %= MOD;
        rem++;
      }
    } else {
      if (rem <= 0)
        rem--;
      else {
        (ans *= rem) %= MOD;
        rem--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}