#include using namespace std; #define rep(i,a,b) for(LL i = a;ib; i--) #define tobirep(i,a,b,c) for(LL i = a;ib; i-=c) #define INF ((1LL<<62)-(1LL<<31)) #define ooki 9223372036854775807 #define tii -9223372036854775808 typedef long long LL; int main(){ LL n,sum=0; cin >> n; vector a(n); vector b(n); vector vec(n); rep(i,0,n){cin >> a[i];vec[i]=i;} rep(i,0,n){cin >> b[i];} sort(a.begin(),a.end()); sort(b.begin(),b.end()); reverse(a.begin(),a.end()); rep(i,0,n){ if(a[i]>=b[i]){sum+=a[i]-b[i];} } LL count = 0; do{ LL sum2 = 0; rep(i,0,n){ if(a[i]>=b[vec[i]]){sum2+=a[i]-b[vec[i]];} } if(sum2==sum){count++;} } while(next_permutation(vec.begin(),vec.end())); cout << count << endl; }