import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class WritingCode {
static int N,M,B,MOD;
static int arr[] = new int[502];
static int dp[][][] = new int[2][502][502];
IReader in
= new IReader
(System.
in); N = in.i();
M = in.i();
B = in.i();
MOD = in.i();
for(int i=1;i<=N;i++) arr[i] = in.i();
dp[0][0][0] = 1;
for(int i=1;i<=N;i++){
dp[(i)&1][0][0] =1;
for(int j=1;j<=M;j++){
for(int k=0;k<=B;k++){
dp[i&1][j][k] += dp[(i-1)&1][j][k]%MOD;
if(k-arr[i]>=0) dp[(i)&1][j][k] += (dp[(i)&1][j-1][k-arr[i]])%MOD;
}
}
}
long sum = 0;
for(int k=0;k<=B;k++) sum+= dp[N&1][M][k]%MOD;
}
}
class IReader {
tokenizer = null;
}
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
}
}
return tokenizer.nextToken();
}
public int i() {
}
}
aW1wb3J0IGphdmEuaW8uQnVmZmVyZWRSZWFkZXI7CmltcG9ydCBqYXZhLmlvLklPRXhjZXB0aW9uOwppbXBvcnQgamF2YS5pby5JbnB1dFN0cmVhbTsKaW1wb3J0IGphdmEuaW8uSW5wdXRTdHJlYW1SZWFkZXI7CmltcG9ydCBqYXZhLnV0aWwuU3RyaW5nVG9rZW5pemVyOwoKCnB1YmxpYyBjbGFzcyBXcml0aW5nQ29kZSB7CglzdGF0aWMgaW50IE4sTSxCLE1PRDsKCXN0YXRpYyBpbnQgYXJyW10gPSBuZXcgaW50WzUwMl07CglzdGF0aWMgaW50IGRwW11bXVtdID0gbmV3IGludFsyXVs1MDJdWzUwMl07CgoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW11hcmdzKSB0aHJvd3MgVGhyb3dhYmxlewoJCUlSZWFkZXIgaW4gPSBuZXcgSVJlYWRlcihTeXN0ZW0uaW4pOwoJCU4gPSBpbi5pKCk7CgkJTSA9IGluLmkoKTsKCQlCID0gaW4uaSgpO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