#include using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) using ll = long long; using P = pair; using vi = vector; using vvi = vector; int main(){ int n; cin >> n; vi a(n), b(n), c(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> b[i]; rep(i,n) c[i]=i; sort(a.begin(), a.end()); int ans=0, mx=-1; do{ int sum=0; rep(i,n) sum+=max(0, a[c[i]]-b[i]); if(sum > mx){ mx=sum; ans=0; } if(sum==mx) ans++; }while(next_permutation(c.begin(), c.end())); cout << ans << endl; }