#include // created [2020/02/21] 21:21:37 #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-conversion" using i32 = int32_t; using i64 = int64_t; using u32 = uint32_t; using u64 = uint64_t; using uint = unsigned int; using usize = std::size_t; using ll = long long; using ull = unsigned long long; using ld = long double; template using arr = T (&)[n]; template using c_arr = const T (&)[n]; template using max_heap = std::priority_queue; template using min_heap = std::priority_queue, std::greater>; template constexpr T popcount(const T u) { return u ? static_cast(__builtin_popcountll(static_cast(u))) : static_cast(0); } template constexpr T log2p1(const T u) { return u ? static_cast(64 - __builtin_clzll(static_cast(u))) : static_cast(0); } template constexpr T msbp1(const T u) { return log2p1(u); } template constexpr T lsbp1(const T u) { return __builtin_ffsll(u); } template constexpr T clog(const T u) { return u ? log2p1(u - 1) : static_cast(u); } template constexpr bool ispow2(const T u) { return u and (static_cast(u) & static_cast(u - 1)) == 0; } template constexpr T ceil2(const T u) { return static_cast(1) << clog(u); } template constexpr T floor2(const T u) { return u == 0 ? static_cast(0) : static_cast(1) << (log2p1(u) - 1); } template constexpr bool btest(const T mask, const usize ind) { return static_cast((static_cast(mask) >> ind) & static_cast(1)); } template void bset(T& mask, const usize ind) { mask |= (static_cast(1) << ind); } template void breset(T& mask, const usize ind) { mask &= ~(static_cast(1) << ind); } template void bflip(T& mask, const usize ind) { mask ^= (static_cast(1) << ind); } template void bset(T& mask, const usize ind, const bool b) { (b ? bset(mask, ind) : breset(mask, ind)); } template constexpr T bcut(const T mask, const usize ind) { return ind == 0 ? static_cast(0) : static_cast((static_cast(mask) << (64 - ind)) >> (64 - ind)); } template bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); } template bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); } constexpr unsigned int mod = 1000000007; template constexpr T inf_v = std::numeric_limits::max() / 4; template constexpr Real pi_v = Real{3.141592653589793238462643383279502884}; auto mfp = [](auto&& f) { return [=](auto&&... args) { return f(f, std::forward(args)...); }; }; template T in() { T v; return std::cin >> v, v; } template T in_v(typename std::enable_if<(i == n), c_arr>::type) { return in(); } template auto in_v(typename std::enable_if<(i < n), c_arr>::type& szs) { const usize s = (usize)szs[i]; std::vector(szs))> ans(s); for (usize j = 0; j < s; j++) { ans[j] = in_v(szs); } return ans; } template auto in_v(c_arr szs) { return in_v(szs); } template auto in_t() { return std::tuple...>{in()...}; } struct io_init { io_init() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(20); } void clear() { std::cin.tie(), std::ios::sync_with_stdio(true); } } io_setting; int out() { return 0; } template int out(const T& v) { return std::cout << v, 0; } template int out(const std::vector& v) { for (usize i = 0; i < v.size(); i++) { if (i > 0) { std::cout << ' '; } out(v[i]); } return 0; } template int out(const std::pair& v) { return out(v.first), std::cout << ' ', out(v.second), 0; } template int out(const T& v, const Args... args) { return out(v), std::cout << ' ', out(args...), 0; } template int outln(const Args... args) { return out(args...), std::cout << '\n', 0; } template int outel(const Args... args) { return out(args...), std::cout << std::endl, 0; } # define SHOW(...) static_cast(0) constexpr ull TEN(const usize n) { return n == 0 ? 1ULL : TEN(n - 1) * 10ULL; } template auto make_v(typename std::enable_if<(i == n), c_arr>::type, const T& v = T{}) { return v; } template auto make_v(typename std::enable_if<(i < n), c_arr>::type szs, const T& v = T{}) { const usize s = (usize)szs[i]; return std::vector(szs, v))>(s, make_v(szs, v)); } template auto make_v(c_arr szs, const T& t = T{}) { return make_v(szs, t); } template class matrix { public: using value_type = Ring; matrix(const usize row, const usize column) : row{row}, column{column}, table(row, std::vector(column, 0)) {} matrix(const matrix& m) : row{m.row}, column{m.column}, table{m.table} {} matrix& operator=(const matrix& m) { assert(row == m.row), assert(column == m.column); for (usize i = 0; i < row; i++) { for (usize j = 0; j < column; j++) { table[i][j] = m[i][j]; } } return *this; } const std::vector& operator[](const usize r) const { return assert(r < row), table[r]; } std::vector& operator[](const usize r) { return assert(r < row), table[r]; } friend matrix operator+(const matrix& m) { return m; } friend matrix operator-(const matrix& m) { matrix ans(m.row, m.column); for (usize r = 0; r < m.row; r++) { for (usize c = 0; c < m.column; c++) { ans.table[r][c] = -m.table[r][c]; } } return ans; } friend matrix operator+(const matrix& m1, const matrix& m2) { assert(m1.row == m2.row), assert(m1.column == m2.column); matrix ans(m1.row, m1.column); for (usize i = 0; i < m1.row; i++) { for (usize j = 0; j < m1.column; j++) { ans[i][j] = m1.table[i][j] + m2.table[i][j]; } } return ans; } friend matrix operator-(const matrix& m1, const matrix& m2) { assert(m1.row == m2.row), assert(m1.column == m2.column); matrix ans(m1.row, m1.column); for (usize i = 0; i < m1.row; i++) { for (usize j = 0; j < m1.column; j++) { ans[i][j] = m1.table[i][j] - m2.table[i][j]; } } return ans; } friend matrix operator*(const matrix& m1, const matrix& m2) { assert(m1.column == m2.row); matrix ans(m1.row, m2.column); for (usize i = 0; i < m1.row; i++) { for (usize j = 0; j < m2.column; j++) { for (usize k = 0; k < m1.column; k++) { ans[i][j] += m1.table[i][k] * m2.table[k][j]; } } } return ans; } friend matrix operator*(const matrix& m, const value_type& t) { matrix ans(m.row, m.column); for (usize i = 0; i < m.row; i++) { for (usize j = 0; j < m.column; j++) { ans[i][j] = m.table[i][j] * t; } } return ans; } friend matrix operator/(const matrix& m, const value_type& t) { assert(t != static_cast(0)); matrix ans(m.row, m.column); for (usize i = 0; i < m.row; i++) { for (usize j = 0; j < m.column; j++) { ans[i][j] = m.table[i][j] / t; } } return ans; } friend matrix operator*(const value_type& t, const matrix& m) { return m * t; } friend matrix operator^(const matrix& m, const unsigned long long n) { return assert(m.row == m.column), n == 0 ? matrix::id(m.row) : n % 2 == 1 ? m*(m ^ (n - 1)) : ((m * m) ^ (n / 2)); } friend matrix& operator+=(matrix& m1, const matrix& m2) { assert(m1.row == m2.row), assert(m1.column == m2.column); for (usize i = 0; i < m1.row; i++) { for (usize j = 0; j < m1.column; j++) { m1.table[i][j] += m2.table[i][j]; } } return m1; } friend matrix& operator-=(matrix& m1, const matrix& m2) { assert(m1.row == m2.row), assert(m1.column == m2.column); for (usize i = 0; i < m1.row; i++) { for (usize j = 0; j < m1.column; j++) { m1.table[i][j] -= m2.table[i][j]; } } return m1; } friend matrix& operator*=(matrix& m1, const matrix& m2) { return m1 = m1 * m2; } friend matrix& operator*=(matrix& m, const value_type& t) { for (usize i = 0; i < m.row; i++) { for (usize j = 0; j < m.column; j++) { m.table[i][j] *= t; } } return m; } friend matrix& operator/=(matrix& m, const value_type& t) { assert(t != 0); for (usize i = 0; i < m.row; i++) { for (usize j = 0; j < m.column; j++) { m.table[i][j] /= t; } } return m; } friend matrix& operator^=(matrix& m, const unsigned long long n) { return m = m ^ n; } friend std::ostream& operator<<(std::ostream& os, const matrix& m) { os << "[\n"; for (usize i = 0; i < m.row; i++) { os << "["; for (usize j = 0; j < m.column; j++) { os << m[i][j] << ","; } os << "]\n"; } return (os << "]\n"); } static matrix id(const usize N) { matrix ans(N, N); for (usize i = 0; i < N; i++) { ans[i][i] = 1; } return ans; } const usize row, column; private: std::vector> table; }; template T gcd(const T& a, const T& b) { return a < 0 ? gcd(-a, b) : b < 0 ? gcd(a, -b) : (a > b ? gcd(b, a) : a == 0 ? b : gcd(b % a, a)); } template T lcm(const T& a, const T& b) { return a / gcd(a, b) * b; } template constexpr std::pair extgcd(const T a, const T b) { if (b == 0) { return std::pair{1, 0}; } const auto g = gcd(a, b), da = std::abs(b) / g; const auto p = extgcd(b, a % b); const auto x = (da + p.second % da) % da, y = (g - a * x) / b; return {x, y}; } template constexpr T inverse(const T a, const T mod) { return extgcd(a, mod).first; } template class modint_base { public: template static std::enable_if_t mod() { return mod_ref(); } template static constexpr std::enable_if_t mod() { return mod_value; } template static void set_mod(const std::enable_if_t mod) { mod_ref() = mod, inv_ref() = {1, 1}; } modint_base() : v{0} {} modint_base(const ll val) : v{norm(static_cast(val % static_cast(mod()) + static_cast(mod())))} {} modint_base(const modint_base& n) : v{n()} {} explicit operator bool() const { return v != 0; } bool operator!() const { return not static_cast(*this); } modint_base& operator=(const modint_base& m) { return v = m(), (*this); } modint_base& operator=(const ll val) { return v = norm(uint(val % static_cast(mod()) + static_cast(mod()))), (*this); } friend modint_base operator+(const modint_base& m) { return m; } friend modint_base operator-(const modint_base& m) { return make(norm(mod() - m.v)); } friend modint_base operator+(const modint_base& m1, const modint_base& m2) { return make(norm(m1.v + m2.v)); } friend modint_base operator-(const modint_base& m1, const modint_base& m2) { return make(norm(m1.v + mod() - m2.v)); } friend modint_base operator*(const modint_base& m1, const modint_base& m2) { return make(static_cast(static_cast(m1.v) * static_cast(m2.v) % static_cast(mod()))); } friend modint_base operator/(const modint_base& m1, const modint_base& m2) { return m1 * inv(m2.v); } friend modint_base operator+(const modint_base& m, const ll val) { return modint_base{static_cast(m.v) + val}; } friend modint_base operator-(const modint_base& m, const ll val) { return modint_base{static_cast(m.v) - val}; } friend modint_base operator*(const modint_base& m, const ll val) { return modint_base{static_cast(m.v) * (val % static_cast(mod()))}; } friend modint_base operator/(const modint_base& m, const ll val) { return modint_base{static_cast(m.v) * inv(val)}; } friend modint_base operator+(const ll val, const modint_base& m) { return modint_base{static_cast(m.v) + val}; } friend modint_base operator-(const ll val, const modint_base& m) { return modint_base{-static_cast(m.v) + val}; } friend modint_base operator*(const ll val, const modint_base& m) { return modint_base{static_cast(m.v) * (val % static_cast(mod()))}; } friend modint_base operator/(const ll val, const modint_base& m) { return modint_base{val * inv(static_cast(m.v))}; } friend modint_base& operator+=(modint_base& m1, const modint_base& m2) { return m1 = m1 + m2; } friend modint_base& operator-=(modint_base& m1, const modint_base& m2) { return m1 = m1 - m2; } friend modint_base& operator*=(modint_base& m1, const modint_base& m2) { return m1 = m1 * m2; } friend modint_base& operator/=(modint_base& m1, const modint_base& m2) { return m1 = m1 / m2; } friend modint_base& operator+=(modint_base& m, const ll val) { return m = m + val; } friend modint_base& operator-=(modint_base& m, const ll val) { return m = m - val; } friend modint_base& operator*=(modint_base& m, const ll val) { return m = m * val; } friend modint_base& operator/=(modint_base& m, const ll val) { return m = m / val; } friend modint_base operator^(const modint_base& m, const ll n) { return power(m.v, n); } friend modint_base& operator^=(modint_base& m, const ll n) { return m = m ^ n; } friend bool operator==(const modint_base& m1, const modint_base& m2) { return m1.v == m2.v; } friend bool operator!=(const modint_base& m1, const modint_base& m2) { return not(m1 == m2); } friend bool operator==(const modint_base& m, const ll val) { return m.v == norm(static_cast(static_cast(mod()) + val % static_cast(mod()))); } friend bool operator!=(const modint_base& m, const ll val) { return not(m == val); } friend bool operator==(const ll val, const modint_base& m) { return m.v == norm(static_cast(static_cast(mod()) + val % static_cast(mod()))); } friend bool operator!=(const ll val, const modint_base& m) { return not(m == val); } friend std::istream& operator>>(std::istream& is, modint_base& m) { ll v; return is >> v, m = v, is; } friend std::ostream& operator<<(std::ostream& os, const modint_base& m) { return os << m(); } uint operator()() const { return v; } static modint_base small_inv(const usize n) { auto& in = inv_ref(); if (n < in.size()) { return in[n]; } for (usize i = in.size(); i <= n; i++) { in.push_back(-in[modint_base::mod() % i] * (modint_base::mod() / i)); } return in.back(); } std::pair quad() const { const auto ans = quad_r(v, mod()); ll x = std::get<0>(ans), y = std::get<1>(ans); if (y < 0) { x = -x, y = -y; } return {x, y}; } private: static std::tuple quad_r(const ll r, const ll p) // r = x/y (mod p), (x,y,z) s.t. x=yr+pz { if (std::abs(r) <= 1000) { return {r, 1, 0}; } ll nr = p % r, q = p / r; if (nr * 2LL >= r) { nr -= r, q++; } if (nr * 2LL <= -r) { nr += r, q--; } const auto sub = quad_r(nr, r); const ll x = std::get<0>(sub), z = std::get<1>(sub), y = std::get<2>(sub); return {x, y - q * z, z}; } template static std::enable_if_t mod_ref() { static UInt mod = 0; return mod; } static uint norm(const uint x) { return x < mod() ? x : x - mod(); } static modint_base make(const uint x) { modint_base m; return m.v = x, m; } static modint_base power(modint_base x, ull n) { modint_base ans = 1; for (; n; n >>= 1, x *= x) { if (n & 1) { ans *= x; } } return ans; } static modint_base inv(const ll v) { return v <= 2000000 ? small_inv(static_cast(v)) : modint_base{inverse(v, static_cast(mod()))}; } static std::vector& inv_ref() { static std::vector in{1, 1}; return in; } uint v; }; template using modint = modint_base; template using dynamic_modint = modint_base; int main() { using mint = modint; const auto N = in(), W = in(); const auto K = in(); const auto as = in_v({N}); std::vector dp(W + 1, 0); dp[0] = 1; for (int i = 1; i <= W; i++) { for (int j = 0; j < N; j++) { if (i - as[j] < 0) { continue; } dp[i] += dp[i - as[j]]; } } SHOW(dp); matrix trans(2 * W, 2 * W); // -w,-(w-1),..-1, 0,1,2...,w-1 for (int i = 0; i < W; i++) { for (int j = 0; j < W; j++) { if (i != 0 and j != 0) { continue; } for (int k = 0; k < N; k++) { const int pi = (j + W) - as[k]; if (pi < i or pi >= W) { continue; } trans[i][j] += dp[pi - i]; } if (j == 0) { for (int k = 0; k < N; k++) { const int pi = (j + 2 * W) - as[k]; if (pi < 0 or pi >= W) { continue; } trans[W][j] += dp[pi]; } } } } SHOW(trans); const auto A = trans ^ K; outln(A[0][0]); return 0; }