#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]; } std::vector factors(N), alphas(N); 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; alphas[i] = alpha; factors[i] = (alpha * B + beta) % MOD; } std::vector left(N, 1), right(N, 1); for (int i = 0; i < N - 1; i++) { left[i + 1] = left[i] * factors[i] % MOD; } for (int i = N - 1; i >= 1; i--) { right[i - 1] = right[i] * factors[i] % MOD; } ll ans = 0; for (int i = 0; i < N; i++) { (ans += (left[i] * right[i] % MOD) * alphas[i] % MOD) %= MOD; } std::cout << ans * B % MOD << std::endl; }