#include #define int long long using namespace std; void file_IO(){ freopen("spice.in", "r", stdin); freopen("spice.out", "w", stdout); } const int N = 85; const int MOD = 1e9 + 7; int n, c, ans = 0, v[N]; int fp(int x, int y){ int res = 1; while (y){ if (y & 1) res = res * x % MOD; x = x * x % MOD, y >>= 1; } return res; } void add(int &x, int y){ x = (x + y >= MOD ? x + y - MOD : x + y); } void sub(int &x, int y){ x = (x >= y ? x - y : x + MOD - y); } struct matrix{ int a[N][N]; matrix(){ memset(a, 0, sizeof(a)); } matrix operator * (const matrix& b) const{ matrix c; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int k = 1; k <= n; k++) add(c.a[i][j], a[i][k] * b.a[k][j] % MOD); return c; } void print(){ cout << "Size: " << n << " * " << n << endl; for (int i = 1; i <= n; i++){ for (int j = 1; j <= n; j++) cout << a[i][j] << " " ; cout << endl; } } }res, base; void calc(int x){ while (x){ if (x & 1) res = res * base; base = base * base, x >>= 1; } } signed main(){ //file_IO(); cin >> n >> c; for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 1; i <= n; i++) res.a[1][i] = v[i]; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) base.a[i][j] = (i <= j ? v[j] : 0); calc(c - 1); for (int i = 1; i <= n; i++) add(ans, res.a[1][i]); for (int i = 1; i <= n; i++) sub(ans, fp(v[i], c)); cout << ans << endl; return 0; }