#include using namespace std; int main(){ int N; cin >> N; vector a(N); for (int i = 0; i < N; i++){ cin >> a[i]; } vector b(N); for (int i = 0; i < N; i++){ cin >> b[i]; } vector p(N); for (int i = 0; i < N; i++){ p[i] = i; } long long mx = -1; int mxcnt = 0; while (1){ long long t = 0; for (int i = 0; i < N; i++){ t += max(a[p[i]] - b[i], (long long) 0); } if (t > mx){ mx = t; mxcnt = 1; } else if (t == mx){ mxcnt++; } if (!next_permutation(p.begin(), p.end())){ break; } } cout << mxcnt << endl; }