Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Counter
- MOD, N = 10**9 + 7, 10**5 + 2
- fact = [1] + [j for j in [1] for i in xrange(1, N) for j in [(j * i) % MOD]]
- inv = [pow(fact[i], MOD - 2, MOD) for i in xrange(N)]
- def C(h, k): return (fact[h] * inv[k] * inv[h - k]) % MOD
- n, d = raw_input(), Counter(map(int, raw_input().split())).most_common()
- print (reduce(lambda x, y: (x * C(d[0][1], y[1]) * fact[y[1]]) % MOD, d, 1) * inv[d[0][1]]) % MOD
Add Comment
Please, Sign In to add comment