#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() #define CLR(t,v) memset(t,(v),sizeof(t)) templateostream& operator<<(ostream& os,const pair&a){return os<<"("<void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<void chmin(T&a,const T&b){if(a>b)a=b;} templatevoid chmax(T&a,const T&b){if(a= MOD) x -= MOD;return *this;} mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;} mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;} mint operator+(const mint a) const {mint res(*this);return res+=a;} mint operator-(const mint a) const {mint res(*this);return res-=a;} mint operator*(const mint a) const {mint res(*this);return res*=a;} mint pow(ll b) const { mint res(1), a(*this); while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; } // for prime MOD mint inv() const {return pow(MOD-2);} mint& operator/=(const mint a) {return (*this) *= a.inv();} mint operator/(const mint a) const {mint res(*this);return res/=a;} }; #define SZ(v) ((int)(v).size()) using Array = vector; using Matrix = vector; Matrix zero(int N){ return Matrix(N, Array(N)); } Matrix identity(int N) { Matrix A = zero(N); REP(i, N) A[i][i] = 1; return A; } Matrix add(const Matrix &A, const Matrix& B){ const int N = SZ(A); const int M = SZ(A[0]); Matrix C(N, Array(M)); REP(i, N) REP(j, M) { C[i][j] += A[i][j] + B[i][j]; if (C[i][j] >= MOD) C[i][j] %= MOD; } return C; } Array mul(const Matrix &A, const Array &x){ const int N = SZ(A); const int M = SZ(A[0]); Array y(N); REP(i, N) REP(j, M) y[i] += A[i][j] * x[j]; return y; } // A:[N,P] * B:[P,M] = C:[N,M] Matrix mul(const Matrix &A, const Matrix& B) { const int N = SZ(A); const int P = SZ(A[0]); const int M = SZ(B[0]); Matrix C(N, Array(M)); REP(i, N) REP(j, M) REP(k, P) { C[i][j] += A[i][k] * B[k][j]; if (C[i][j] >= MOD) C[i][j] %= MOD; } return C; } Matrix pow(Matrix A, ll b) { Matrix C = identity(SZ(A)); while (b > 0) { if ((b & 1) == 1) C = mul(C, A); A = mul(A, A); b >>= 1; } return C; } int main2() { int N = nextInt(); int W = nextInt(); ll K = nextLong(); vector A(N); REP(i, N) A[i] = nextInt(); Matrix X = identity(2*W); mint ways[2*W][2]; REP(w0, W) REP(j0, 2) { REP(w, 2*W) REP(j, 2) ways[w][j] = 0; ways[w0][j0] = 1; REP(w, W) REP(j, 2) { REP(i, N) { int nw = w + A[i]; if (nw < W) { ways[nw][j] += ways[w][j]; } else if (nw <= 2*W) { int nj = (nw == W) ? 0 : 1; if (j == 1 && nj == 1) continue; ways[nw][nj] += ways[w][j]; } } } for (int w = W; w < 2*W; w++) { for (int j = 0; j < 2; j++) { int a = (w - W) + j *W; int b = (w0 ) + j0*W; X[b][a] = ways[w][j].x; } } } // REP(i, 2*W) { // REP(j, 2*W) { // cout << X[i][j] << " "; // } // cout << endl; // } X = pow(X, K); Array b = Array(2*W); b[0] = 1; auto v = mul(X, b); ll ans = v[0]; cout << ans << endl; return 0; } int main() { #ifdef LOCAL for (;!cin.eof();cin>>ws) #endif main2(); return 0; }