#include #define rep(i,n) for(int i=0;i pp; const int INF = 1e9; const int MOD = 1000000007; typedef vector vec; typedef vector mat; mat mul(mat &A, mat &B) { mat C(A.size(),vec(B[0].size())); for(int i=0;i 0){ if(n & 1) B = mul(B,A); A = mul(A,A); n >>= 1; } return B; } int main() { int n,w; ll k; cin >> n >> w >> k; vector p(n); rep(i,n) cin >> p[i]; vector dp(2*w+1); dp[0] = 1; for(int i=1;i<=w;i++){ rep(j,n){ if(i - p[j] >= 0) dp[i] = (dp[i] + dp[i-p[j]])%MOD; } } ll a = dp[w]; if(k ==1){ cout << a << endl; return 0; } dp[w] = 0; for(int i=w+1;i<=2*w;i++){ rep(j,n){ if(i - p[j] >= 0) dp[i] = (dp[i] + dp[i-p[j]])%MOD; } } ll b = dp[2*w]; if(k ==2){ cout << ((a*a)%MOD + b)%MOD << endl; return 0; } mat A = {{a,b},{1LL,0LL}}; mat B = pow(A,k-2); ll ans = ((B[0][0] * ((a*a)%MOD+b)%MOD)%MOD + (B[0][1] * a)%MOD)%MOD; cout << ans << endl; return 0; }