import std.algorithm, std.conv, std.range, std.stdio, std.string; void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}} T[] readArray(T)(size_t n){auto a=new T[](n),r=readln.splitter;foreach(ref v;a){v=r.front.to!T;r.popFront;}return a;} T[] readArrayM(T)(size_t n){auto a=new T[](n);foreach(ref v;a)v=readln.chomp.to!T;return a;} const mod = 10^^9+7; alias mint = FactorRing!mod; void main() { int n; long c; readV(n, c); auto a = readArray!int(n); auto m = Matrix!mint(n, n), u = Matrix!mint.unit(n); foreach (i; 0..n) foreach (j; 0..n) if (j <= i) m[i][j] = a[j]; auto r = repeatedSquare(m, c, u); auto ans = mint(0); foreach (i; 0..n) ans += r[n-1][i] - r[i][i]; writeln(ans); } pure T repeatedSquare(alias pred = "a * b", T, U)(T a, U n, T init) { import std.functional; alias predFun = binaryFun!pred; if (n == 0) return init; auto r = init; while (n > 0) { if (n&1) r = predFun(r, a); a = predFun(a, a); n >>= 1; } return r; } struct Matrix(T) { size_t r, c; T[][] a; alias a this; static ref auto unit(size_t n) { auto r = Matrix!T(n, n); foreach (i; 0..n) r[i][i] = 1; return r; } this(size_t r, size_t c) { this.r = r; this.c = c; a = new T[][](r, c); static if (T.init != 0) foreach (i; 0..r) a[i][] = 0; } ref auto opBinary(string op)(ref Matrix!T b) if (op == "+" || op == "-") in { assert(r == b.r && c == b.c); } body { auto x = Matrix!T(r, c); foreach (i; 0..r) foreach (j; 0..c) x[i][j] = mixin("a[i][j]"~op~"b[i][j]"); return x; } ref auto opBinary(string op: "*")(ref Matrix!T b) in { assert(c == b.r); } body { auto x = Matrix!T(r, b.c); foreach (i; 0..r) foreach (j; 0..b.c) foreach (k; 0..c) x[i][j] += a[i][k]*b[k][j]; return x; } } struct FactorRing(int m, bool pos = false) { version(BigEndian) union { long vl; struct { int vi2; int vi; } } else union { long vl; int vi; } static init() { return FactorRing!(m, pos)(0); } @property int toInt() { return vi; } alias toInt this; this(int v) { vi = v; } this(int v, bool runMod) { vi = runMod ? mod(v) : v; } this(long v) { vi = mod(v); } ref auto opAssign(int v) { vi = v; return this; } pure auto mod(int v) const { static if (pos) return v%m; else return (v%m+m)%m; } pure auto mod(long v) const { static if (pos) return cast(int)(v%m); else return cast(int)((v%m+m)%m); } static if (!pos) pure auto opUnary(string op: "-")() { return FactorRing!(m, pos)(mod(-vi)); } static if (m < int.max / 2) { pure auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FactorRing!(m, pos)(mod(mixin("vi"~op~"r"))); } ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vi"~op~"r")); return this; } } else { pure auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FactorRing!(m, pos)(mod(mixin("vl"~op~"r"))); } ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vl"~op~"r")); return this; } } pure auto opBinary(string op: "*")(int r) { return FactorRing!(m, pos)(mod(vl*r)); } ref auto opOpAssign(string op: "*")(int r) { vi = mod(vl*r); return this; } pure auto opBinary(string op)(FactorRing!(m, pos) r) if (op == "+" || op == "-" || op == "*") { return opBinary!op(r.vi); } ref auto opOpAssign(string op)(FactorRing!(m, pos) r) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(r.vi); } }