#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include using namespace std; const int mod = 1e9 + 7; uint32_t inv; int r2; int reduce(uint64_t x) { uint64_t y = uint64_t(uint32_t(x) * inv) * mod; int res = int(x >> 32) - int(y >> 32); return res < 0 ? res + mod : res; } int transform(int n) { return reduce(1ULL * n * r2); } void initMontgomeryReduction() { inv = 1; for (int i = 0; i < 5; i++) { inv *= 2 - inv * uint32_t(mod); } r2 = -uint64_t(mod) % mod; } int add(int a, int b) { return (a += b) >= mod ? a - mod : a; } int mul(int a, int b) { return reduce(1ULL * a * b); } int modpow(int a, long long b) { int ret = 1; while (b > 0) { if (b & 1) { ret = 1LL * ret * a % mod; } a = 1LL * a * a % mod; b >>= 1; } return ret; } int main() { initMontgomeryReduction(); int n; long long c; cin >> n >> c; long long foo = 0; vector a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); foo += mod - modpow(a[i], c); a[i] = transform(a[i]); } // doubling // ref: https://yukicoder.me/problems/no/137 vector dp(n * 2); dp[0] = transform(1); while (c > 0) { for (int i = 0; i < n; i++) { for (int j = n * 2 - 2; j >= 0; j--) { dp[j + 1] = add(dp[j + 1], mul(dp[j], a[i])); } } int cc = c & 1; for (int j = 0; j < n; j++) { dp[j] = dp[j * 2 + cc]; } for (int j = n; j < n * 2; j++) { dp[j] = 0; } for (int i = 0; i < n; i++) { a[i] = mul(a[i], a[i]); } c >>= 1; } printf("%d\n", add(reduce(dp[0]), foo % mod)); }