#include <bits/stdc++.h>
#include <boost/functional/hash.hpp>

#define debug 0
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define ins insert
#define emp emplace
#define era erase
#define fir first
#define sec second
#define odd(x) (x & 1)
#define even(x) (!odd(x))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;
typedef tuple<int,int,int> tiii;

const int dir[][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

template <class T, class U> T qceil(T x, U y) { return x > 0 ? (x - 1) / y + 1 : x / y; }
template <class T, class U> bool parity(T x, U y) { return odd(x) ^ even(y); }
template <class T, class U> bool chmax(T &m, U x) { if(m < x) { m = x; return 1; } return 0; }
template <class T, class U> bool chmin(T &m, U x) { if(m > x) { m = x; return 1; } return 0; }
template <class T> bool cmprs(T &v) {
    T tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return v.size() > tmp.size();
}

struct Table {
    ll md;
    vct<ll> fact_tbl,invfact_tbl;
    vct<vct<ll>> comb_tbl;

    Table(int n, ll m = mod) {
        md = m;
        fact_init(n);
        invfact_init(n);
        //comb_init(n);
    }

    ll fact(int x) {
        return fact_tbl[x];
    }

    ll invfact(int x) {
        return invfact_tbl[x];
    }

    ll comb(int x, int y) {
        if(x < y || y < 0) return 0;
        return comb_tbl[x][y];
    }

    void fact_init(int n) {
        fact_tbl.resize(n + 1);
        fact_tbl[0] = 1;
        rep1(i,n) fact_tbl[i] = fact_tbl[i - 1] * i % md;
    }

    void invfact_init(int n) {
        invfact_tbl.resize(n + 1);
        rep(i,n + 1) invfact_tbl[i] = modinv(fact(i));
    }

    void comb_init(int n) {
        comb_tbl.resize(n + 1);
        comb_tbl[0].assign(1,1);
        rep1(i,n) {
            comb_tbl[i].resize(i + 1);
            rep(j,i/2 + 1) {
                comb_tbl[i][j] = comb_tbl[i][i - j] = (comb(i - 1,j - 1) + comb(i - 1,j)) % md;
            }
        }
    }

    ll modpow(ll n, ll e) {
        n %= md,e %= md - 1;
        ll ret = 1;
        while(e) {
            if(e & 1) ret = ret * n % md;
            n = n * n % md;
            e /= 2;
        }
        return ret;
    }

    ll modinv(ll n) {
        return modpow(n,md - 2);
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,a[100100],b[100100];
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    ll ans = 1;
    int l[100010],r[100010];
    for(int i=0,j=n-1;i<n;i++,j--){
        l[i]=i?l[i-1]:0;
        r[i]=i?r[i-1]:0;
        while(l[i]<n&&b[l[i]]<a[i]) ++l[i];
        while(r[i]<n&&a[r[i]]<b[i]) ++r[i];
    }
    for(int i=0;i<n;i++,ans%=mod){
        int j=max(i,l[i]);
        int k=max(i,r[i]);
        ans*=k+j-2*i;
    }
    esc(ans);
}


Measured memory_bytes: 1792