#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; i++) int main() { cin.tie(nullptr); int N; cin >> N; vector> a(N); vector b(N); rep(i, 0, N) { cin >> a[i].first; a[i].second = i; } rep(i, 0, N) cin >> b[i]; sort(a.begin(), a.end()); ll maxi = -1; int ans = 0; do { ll sum = 0; rep(i, 0, N) sum += max(0, a[i].first - b[i]); if (sum > maxi) { maxi = sum; ans = 1; } else if (sum == maxi) { ans++; } } while (next_permutation(a.begin(), a.end())); cout << ans << '\n'; }