/*input
3 3 3 100
1 1 1
*/
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define pii pair<long long,long long>
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define PI 3.14159265
#define ll long long
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define debug(x) cout << #x << " = " << x << endl
#define INF 1000000009
ll n,m,b,mod,ans;
ll arr[1000];
ll f(ll lines,ll progid,ll bugs)
{
cout<<progid<<" "<<lines<<" "<<ans<<endl;
if(lines>m || bugs>b || progid>n)
return 0;
if(lines==m && bugs<=b)
return 1;
ans=0;
F(i,0,m)
{
if(lines+i<=m && bugs+i*arr[progid]<=b && progid+1<=n)
ans = ans + f(lines+i,progid+1,bugs+i*arr[progid]);
}
return ans;
}
int main()
{
std::ios::sync_with_stdio(false);
cin>>n>>m>>b>>mod;
F(i,1,n)
cin>>arr[i];
cout<<f(0,1,0)<<endl;
return 0;
}
LyppbnB1dAozIDMgMyAxMDAKMSAxIDEKKi8KI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlPHN0ZGlvLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgcGlpIHBhaXI8bG9uZyBsb25nLGxvbmcgbG9uZz4KI2RlZmluZSBGKGksYSxiKSBmb3IobGwgaSA9IChsbCkoYSk7IGkgPD0gKGxsKShiKTsgaSsrKQojZGVmaW5lIFJGKGksYSxiKSBmb3IobGwgaSA9IChsbCkoYSk7IGkgPj0gKGxsKShiKTsgaS0tKQojZGVmaW5lIFBJIDMuMTQxNTkyNjUKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBmZiBmaXJzdAojZGVmaW5lIHNzIHNlY29uZAojZGVmaW5lIHBiKHgpIHB1c2hfYmFjayh4KQojZGVmaW5lIG1wKHgseSkgbWFrZV9wYWlyKHgseSkKI2RlZmluZSBk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