#include #include using ll = long long; constexpr ll MOD = 1000000007; template class ModCombination { public: ModCombination(const std::size_t n) : fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1) { for (ll i = 2; i <= (ll)n; i++) { fact[i] = (fact[i - 1] * i) % mod, inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod, inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod; } } ll factorial(const std::size_t n) const { return fact[n]; } ll inverse(const std::size_t n) const { return inv[n]; } ll inverseFactorial(const std::size_t n) const { return inv_fact[n]; } private: std::vector fact, inv, inv_fact; }; int main() { int N; ll B; std::cin >> N >> B; ModCombination<> mod(N); std::vector c(N + 1, 0); for (int i = 0; i < N; i++) { int S; std::cin >> S; c[N - S]++; } std::vector C = c; for (int i = 1; i <= N; i++) { C[i] += C[i - 1]; } ll p0 = 1, p1 = 0; for (int i = 0; i < N; i++) { const ll F = mod.factorial(C[i + 1]) * mod.inverseFactorial(C[i]) % MOD; const ll alpha = C[i + 1] == 0 ? 0 : (F * c[i + 1] % MOD) * mod.inverse(C[i + 1]) % MOD; const ll beta = C[i + 1] == 0 ? F : (F * C[i] % MOD) * mod.inverse(C[i + 1]) % MOD; const ll p0_ = p0; p0 = p0 * (alpha * B + beta) % MOD, p1 = ((p0_ * alpha) + p1 * (alpha * B + beta) % MOD) % MOD; } std::cout << p1 * B % MOD << std::endl; }