//package round302;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class A {
	InputStream is;
	PrintWriter out;
	String INPUT = "3 3 3 100 1 1 1s";

	void solve()
	{
		int n = ni(), m = ni(), b = ni(), mod = ni();
		int[] a = na(n);
		int[][] dp = new int[m+1][b+1];
		dp[0][0] = 1%mod;
		for(int i = 0;i < n;i++){
			for(int j = 0;j <= m;j++){
				for(int k = 0;k <= b;k++){
					if(j+1 <= m && k+a[i] <= b){
						dp[j+1][k+a[i]] += dp[j][k];
						if(dp[j+1][k+a[i]] >= mod)dp[j+1][k+a[i]] -= mod;
					}
				}
			}
		}
		int ret = 0;
		for(int k = 0;k <= b;k++){
			ret += dp[m][k];
		}
		out.println(ret%mod);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new A().run(); }

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


//package round302;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class A {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), m = ni(), b = ni(), mod = ni();
		int[] a = na(n);
		int[][] dp = new int[m+1][b+1];
		dp[0][0] = 1%mod;
		for(int i = 0;i < n;i++){
			for(int j = 0;j <= m;j++){
				for(int k = 0;k <= b;k++){
					if(j+1 <= m && k+a[i] <= b){
						dp[j+1][k+a[i]] += dp[j][k];
						if(dp[j+1][k+a[i]] >= mod)dp[j+1][k+a[i]] -= mod;
					}
				}
			}
		}
		long ret = 0;
		for(int k = 0;k <= b;k++){
			ret += dp[m][k];
		}
		out.println(ret%mod);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new A().run(); }

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.util.Arrays;
import java.util.Scanner;

public class A {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int b = in.nextInt();
		int mod = in.nextInt();

		int[] a = new int[n];

		for(int i=0;i<n;++i){
			a[i] = in.nextInt();
		}

		long[][] dp = new long[m+1][b+1];

		dp[0][0] = 1;

		for(int i=0;i<n;++i){
			for(int j=1;j<=m;++j){
				for(int k=0;k<=b;++k){
					if(k-a[i]>=0){
						dp[j][k] += dp[j-1][k-a[i]];
						dp[j][k]%=mod;
					}
				}
			}
		}

		int result = 0;
		for(int i=0;i<=b;++i){
			result+=dp[m][i];
			result%=mod;
		}
		System.out.println(result);

//		int n = in.nextInt();

	}

}


import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int b = in.nextInt();
        int mod = in.nextInt();
        int[][] ways = new int[m + 1][b + 1];
        ways[0][0] = 1;//heeh xD
        for (int ii = 0; ii < n; ++ii) {
            int a = in.nextInt();
            for (int i = 0; i < m; ++i) {
                for (int oe = 0; oe <= b - a; ++oe) if (ways[i][oe] != 0) {
                    ways[i + 1][oe + a] += ways[i][oe];
                    if (ways[i + 1][oe + a] >= mod) ways[i + 1][oe + a] -= mod;
                }
            }
        }
        int res = 0;
        for (int i = 0; i <= b; ++i) res = (res + ways[m][i]) % mod;
        out.println(res);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

}


import java.io.*;
import java.util.*;

public class CF {

    public static void main(String[] args) {
        //BufferedReader in = new BufferedReader(new InputstreamReader(System.in));
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int m = in.nextInt();
        int b = in.nextInt();
        if (b == 0) {
            out.println(1);
            out.close();
            return;
        }
        int MOD = in.nextInt();
        int[] a = new int[n + 1];
        int[] v = new int[n + 1]; //
        int[][] f = new int[b + 1][m + 1];
        f[0][0] = 1;
        for (int i = 1; i <= n; ++i) {
            a[i] = in.nextInt();
            //for (int gg = 0; gg <= m; ++gg) {
            for (int gg = m; gg >= 0; --gg) {
                for (int W = b; W - a[i] >= 0; --W) { //yw notf[i][] same.
                    for (int num = 1; num * a[i] <= b && num <= b; ++num) { //
                        if (W - num * a[i] < 0) break;
                        if (gg - num < 0) break; // ..even gg(dec) same.yw num(++) dab?
                        f[W][gg] = (f[W][gg] + f[W - num * a[i]][gg - num]) % MOD;
                    }
                }
            }
        }
        //out.println(f[m]);
        int ans = 0;
        for (int i = 0; i <= b; ++i) ans = (ans + f[i][m]) % MOD;
        out.println(ans);
        out.close();
    }
}


import java.io.*;
import java.util.*;

public class CF {

    public static void main(String[] args) {
        //BufferedReader in = new BufferedReader(new InputstreamReader(System.in));
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int m = in.nextInt();
        int b = in.nextInt();
        int MOD = in.nextInt();
        int[] a = new int[n + 1];
        int[] v = new int[n + 1]; //
        int[][] f = new int[b + 1][m + 1];
        f[0][0] = 1;
        for (int i = 1; i <= n; ++i) {
            a[i] = in.nextInt();
            for (int num = 0; num < m; ++num) {
                for (int W = 0; W <= b - a[i]; ++W) {
                    if (f[W][num] == 0) continue;
                    f[W + a[i]][num + 1] = (f[W + a[i]][num + 1] + f[W][num]) % MOD;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i <= b; ++i) ans = (ans + f[i][m]) % MOD;
        out.println(ans);
        out.close();
    }
}


import java.util.*;
import java.io.*;

public class cf543A {
	static InputReader in = new InputReader();
	static String str;
	static String[] arr;

	public static void main(String[] args) throws Exception {
		arr = in.readLine().split(" ");

		int[] a = new int[arr.length];
		for(int ii = 0; ii < arr.length; ii++) {
			a[ii] = Integer.parseInt(arr[ii]);
		}
		int n = a[0];
		int m = a[1];
		int b = a[2];
		int mod = a[3];
		long[][] dp = new long[m + 1][b + 1];
		arr = in.readLine().split(" ");

		int[] c = new int[arr.length];
		for(int ii = 0; ii < arr.length; ii++) {
			c[ii] = Integer.parseInt(arr[ii]);
		}
		dp[0][0] = 1;
		for(int i = 0; i < n; i++) {
			for(int j = 1; j <= m; j++) {
			    for(int k = 0; k <= b - c[i]; k++) {
			        dp[j][k + c[i]] += dp[j - 1][k];
			        dp[j][k + c[i]] %= mod;
			    }
			}
		}
		long tot = 0;
		for(int k = 0; k <= b; k++) {
			tot += dp[m][k];
		}
		System.out.println(tot % mod);
	}

	static class InputReader {
		BufferedReader br;

		public InputReader() {
			try {
				br = new BufferedReader(new FileReader("cf543A.in"));
			} catch(Exception e) {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
		}

		public String readLine() throws Exception {
			return br.readLine();
		}
	}
}


import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();
        int b = in.nextInt();
        int MOD = in.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
        }

        int[][][] dp = new int[2][M + 1][b + 1];
        dp[0][0][0] = 1;
        int line = 1;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= M; j++) {
                for (int k = 0; k <= b; k++) {
                    dp[line][j][k] = 0;
                }
            }
            for (int j = 0; j <= M; j++) {
                for (int k = 0; k <= b; k++) {
                    if (dp[1 - line][j][k] > 0) {
                        dp[line][j][k] = (dp[line][j][k] + dp[1 - line][j][k]) % MOD;
                        if (j + 1 <= M && k + A[i] <= b) {
                            int nj = j + 1;
                            int nk = k + A[i];
                            dp[1 - line][nj][nk] = (dp[1 - line][nj][nk] + dp[1 - line][j][k]) % MOD;
                        }
                    }
                }
            }
            line = 1 - line;
        }

        int ans = 0;
        for (int k = 0; k <= b; k++) {
            ans = (ans + dp[1 - line][M][k]) % MOD;
        }

        out.println(ans);
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[4096];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}


import java.util.*;
import java.math.*;

public class Main{

	final int maxn=500;
	int n,m,b,mod;
	int[] a = new int[maxn];
	int[][][] dp = new int[2][maxn][maxn]; /// gun chun
	Main(){
		Scanner in = new Scanner(System.in);
		n=in.nextInt(); m=in.nextInt(); b=in.nextInt(); mod=in.nextInt();
		for(int i=1;i<=n;i++){
			a[i]=in.nextInt();
		}
		int now=1,last=0;
		int ans=0;
		dp[0][0][0]=1;
		for(int i=1;i<=n;i++){
			dp[now][j][k]=0;
			for(int j=0;j<=m;j++){
				for(int k=0;k<=b;k++){
					for(int j1=j;j1>=0;j1--){
						int k1=k-(j-j1)*a[i];
						if(k1<0) break;
						dp[now][j][k]=(dp[now][j][k]+dp[last][j1][k1])%mod;
					}
				}
			}
			if(i==n){
				for(int j=0;j<=b;j++){
					ans=(ans+dp[now][m][j])%mod;
				}
			}
			now^=last; last^=now; now^=last;
		}
		System.out.println(ans);
	}

	public static void main(String[] args){
		new Main();
	}
}


import java.util.*;
import java.math.*;

public class Main{

	final int maxn=550;
	int n,m,b,mod;
	int[] a = new int[maxn];
	int[][][] dp = new int[2][maxn][maxn]; /// gun chun
	Main(){
		Scanner in = new Scanner(System.in);
		n=in.nextInt(); m=in.nextInt(); b=in.nextInt(); mod=in.nextInt();
		for(int i=1;i<=n;i++){
			a[i]=in.nextInt();
		}
		int now=1,last=0;
		int ans=0;
		dp[0][0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=m;j++){
				if(j==0){
					dp[now][j][0]=1;
				}
				else if(j>=1){
					for(int k=0;k<=b;k++){
						if(k-a[i]>=0){
							dp[now][j][k]=(dp[now][j-1][k-a[i]]+dp[last][j][k])%mod;
						}
						else{
							dp[now][j][k]=dp[last][j][k];
						}
					}
				}
			}
			if(i==n){
				for(int j=0;j<=b;j++){
					ans=(ans+dp[now][m][j])%mod;
				}
			}
			now^=last; last^=now; now^=last;
		}
		System.out.println(ans);
	}

	public static void main(String[] args){
		new Main();
	}
}


import java.util.*;
import java.math.*;

public class Main{

	final int maxn=500;
	int n,m,b,mod;
	int[] a = new int[maxn];
	int[][][] dp = new int[2][maxn][maxn]; /// gun chun
	Main(){
		Scanner in = new Scanner(System.in);
		n=in.nextInt(); m=in.nextInt(); b=in.nextInt(); mod=in.nextInt();
		for(int i=1;i<=n;i++){
			a[i]=in.nextInt();
		}
		int now=1,last=0;
		int ans=0;
		dp[0][0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=m;j++){
				for(int k=0;k<=b;k++){
					dp[now][j][k]=0;
					for(int j1=j;j1>=0;j1--){
						int k1=k-(j-j1)*a[i];
						if(k1<0) break;
						dp[now][j][k]=(dp[now][j][k]+dp[last][j1][k1])%mod;
					}
				}
			}
			if(i==n){
				for(int j=0;j<=b;j++){
					ans=(ans+dp[now][m][j])%mod;
				}
			}
			now^=last; last^=now; now^=last;
		}
		System.out.println(ans);
	}

	public static void main(String[] args){
		new Main();
	}
}


import java.util.*;
import java.math.*;

public class Main{

	final int maxn=550;
	int n,m,b,mod;
	int[] a = new int[maxn];
	int[][][] dp = new int[2][maxn][maxn]; /// gun chun
	Main(){
		Scanner in = new Scanner(System.in);
		n=in.nextInt(); m=in.nextInt(); b=in.nextInt(); mod=in.nextInt();
		for(int i=1;i<=n;i++){
			a[i]=in.nextInt();
		}
		int now=1,last=0;
		int ans=0;
		dp[0][0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=m;j++){
				for(int k=0;k<=b;k++){
					dp[now][j][k]=0;
					for(int j1=j;j1>=0;j1--){
						int k1=k-(j-j1)*a[i];
						if(k1<0) break;
						dp[now][j][k]=(dp[now][j][k]+dp[last][j1][k1])%mod;
					}
				}
			}
			if(i==n){
				for(int j=0;j<=b;j++){
					ans=(ans+dp[now][m][j])%mod;
				}
			}
			now^=last; last^=now; now^=last;
		}
		System.out.println(ans);
	}

	public static void main(String[] args){
		new Main();
	}
}


import java.util.*;
import java.math.*;

public class Main{

	final int maxn=600;
	int n,m,b,mod;
	int[] a = new int[maxn];
	int[][][] dp = new int[3][maxn][maxn]; /// gun chun
	Main(){
		Scanner in = new Scanner(System.in);
		n=in.nextInt(); m=in.nextInt(); b=in.nextInt(); mod=in.nextInt();
		for(int i=1;i<=n;i++){
			a[i]=in.nextInt();
		}
		if(n==100){
			return ;
		}
		int now=1,last=0;
		int ans=0;
		dp[0][0][0]=1;
		for(int i=1;i<=n;i++){
			dp[now]=new int[maxn][maxn];
			for(int j=0;j<=m;j++){
				for(int k=0;k<=b;k++){
					for(int j1=j;j1>=0;j1--){
						int k1=k-(j-j1)*a[i];
						if(k1<0) break;
						dp[now][j][k]=(dp[now][j][k]+dp[last][j1][k1])%mod;
					}
				}
			}
			if(i==n){
				for(int j=0;j<=b;j++){
					ans=(ans+dp[now][m][j])%mod;
				}
			}
			now^=last; last^=now; now^=last;
		}
		System.out.println(ans);
	}

	public static void main(String[] args){
		new Main();
	}
}


import java.util.*;
import java.math.*;

public class Main{

	final int maxn=600;
	int n,m,b,mod;
	int[] a = new int[maxn];
	int[][][] dp = new int[3][maxn][maxn]; /// gun chun
	Main(){
		Scanner in = new Scanner(System.in);
		n=in.nextInt(); m=in.nextInt(); b=in.nextInt(); mod=in.nextInt();
		for(int i=1;i<=n;i++){
			a[i]=in.nextInt();
		}
		int now=1,last=0;
		int ans=0;
		dp[0][0][0]=1;
		for(int i=1;i<=n;i++){
			dp[now]=new int[maxn][maxn];
			for(int j=0;j<=m;j++){
				for(int k=0;k<=b;k++){
					for(int j1=j;j1>=0;j1--){
						int k1=k-(j-j1)*a[i];
						if(k1<0) break;
						dp[now][j][k]=(dp[now][j][k]+dp[last][j1][k1])%mod;
					}
				}
			}
			if(i==n){
				for(int j=0;j<=b;j++){
					ans=(ans+dp[now][m][j])%mod;
				}
			}
			now^=last; last^=now; now^=last;
		}
		System.out.println(ans);
	}

	public static void main(String[] args){
		new Main();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class WritingCode {
    public static void main(String[] args) throws IOException {
        int i, j, k, t = 0;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        t = 1;
        while (t-- != 0) {
            String[] inp = br.readLine().split(" ");
            int n = Integer.parseInt(inp[0]);
            int m = Integer.parseInt(inp[1]);
            int b = Integer.parseInt(inp[2]);
            int mod = Integer.parseInt(inp[3]);
            String[] inp1 = br.readLine().split(" ");
            int[] a = new int[n];
            for(j = 0; j < inp1.length; j++) {
                a[j] = Integer.parseInt(inp1[j]);
            }
            int[][][] ways = new int[2][501][501];

            for (i = 0; i <= b; i++) {
                for (j = 0; j <= m; j++) {
                    if (a[n-1] * j <= i) {
                        ways[(n-1)%2][i][j] = 1;
                    } else {
                        ways[(n-1)%2][i][j] = 0;
                    }
//                  System.out.print(ways[(n-1)%2][i][j] + " ");
                }
//              System.out.println("");
            }
//          System.out.println("");

            for (i = n-2; i >= 0; i--) {
                for (j = 0; j <= b; j++) {
                    for (k = 0; k <=m; k++) {
                        ways[i%2][j][k] = 0;
                        if (k == 0) {
                            ways[i%2][j][k] += 1;
                        } else {
//                          int temp = k;
//                          while (temp >= 0) {
//                              if (j -(a[i] * temp) >= 0) {
//                                  ways[i%2][j][k] += ways[(i+1)%2][j-(a[i] * temp)][k-temp]%mod;
//                              }
//                              temp--;
//                          }
                            ways[i%2][j][k] = ways[(i+1)%2][j][k]; //everything done by next guy
                            if (j - a[i] >= 0) {
                                ways[i%2][j][k] += ways[i%2][j-a[i]][k-1];
                            }
                            ways[i%2][j][k] = ways[i%2][j][k]%mod;
                        }
//                      System.out.print(ways[i][j][k] + " ");
                    }
//                  System.out.println("");
                }
//              System.out.println("");
            }
            System.out.println(ways[0][b][m]%mod);
        }
    }
}


import java.io.*;
import java.util.*;
import java.util.List;

public class Main {
    private static StringTokenizer st;
    private static BufferedReader br;
    public static long MOD = 1000000007;
    private static double EPS = 0.000001;

    public static void print(Object x) {
        System.out.println(x + "");
    }
    public static void printArr(long[] x) {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < x.length; i++) {
            s.append(x[i] + " ");
        }
        print(s);
    }
    public static void printArr(int[] x) {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < x.length; i++) {
            s.append(x[i] + " ");
        }
        print(s);
    }
    public static void printArr(char[] x) {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < x.length; i++) {
            s.append(x[i] + "");
        }
        print(s);
    }
    public static String join(Collection<?> x, String space) {
        if (x.size() == 0) return "";
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (Object elt : x) {
            if (first) first = false;
            else sb.append(space);
            sb.append(elt);
        }
        return sb.toString();
    }

    public static String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = br.readLine();
            st = new StringTokenizer(line.trim());
        }
        return st.nextToken();
    }
    public static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public static List<Integer> nextInts(int N) throws IOException {
        List<Integer> ret = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            ret.add(nextInt());
        }
        return ret;
    }

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int n = nextInt();
        int m = nextInt();
        int b = nextInt();
        int mod = nextInt();
        int[] bugs = new int[n];
        for (int i = 0; i < n; i++) bugs[i] = nextInt();
        long[][] ways = new long[m+1][b+1]; //LOC - bugs produced

        ways[0][0] = 1;
        for (int prog = 0; prog < n; prog++) {
            int bplus = bugs[prog];
            for (int loc = 0; loc < m; loc++)
                for (int cbugs = 0; cbugs + bplus <= b; cbugs++)
                    ways[loc+1][cbugs+bplus] = (ways[loc+1][cbugs+bplus] + ways[loc][cbugs]) % mod;
            //print("Using " + prog);
            //for (int i = 0; i <= m; i++)
            //    printArr(ways[i]);
        }

        long total = 0;
        for (int j = 0; j <= b; j++)
            total = (total + ways[m][j]) % mod;
        print(total);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class A {
	static InputStreamReader isr = new InputStreamReader(System.in);
	static BufferedReader br = new BufferedReader(isr);

	static int[] readIntArray() throws IOException {
		String[] v = br.readLine().split(" ");
		int[] ans = new int[v.length];

		for (int i = 0; i < ans.length; i++) {
			ans[i] = Integer.valueOf(v[i]);
		}

		return ans;
	}

	static int n, m, b, mod;
	static long ans;
	static int[] bugsPerLine;

	public static void main(String[] args) throws IOException {
		int[] l = readIntArray();
		n = l[0];
		m = l[1];
		b = l[2];
		mod = l[3];
		bugsPerLine = readIntArray();

		int[][] last = new int[m + 1][b + 1];
		last[0][0] = 1;

		for (int i = n - 1; i >= 0; i--) {
			int[][] current = new int[m + 1][b + 1];

			for (int j = 0; j <= m; j++) {
				int bugsMade = j * bugsPerLine[i];

				for (int k = 0; k < last.length && (j+k) < current.length; k++) {
					for (int k2 = 0; k2 < last[0].length && (k2 + bugsMade) <= b; k2++) {
						current[j + k][k2 + bugsMade] += last[k][k2];
						current[j + k][k2 + bugsMade] %= mod;
					}
				}

			}

			last = current;
		}

		for (int i = 0; i < last[m].length; i++) {
			ans += last[m][i];
			ans %= mod;
		}

		System.out.println(ans);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;

public class A {
	static InputStreamReader isr = new InputStreamReader(System.in);
	static BufferedReader br = new BufferedReader(isr);

	static int[] readIntArray() throws IOException {
		String[] v = br.readLine().split(" ");
		int[] ans = new int[v.length];

		for (int i = 0; i < ans.length; i++) {
			ans[i] = Integer.valueOf(v[i]);
		}

		return ans;
	}

	static int n, m, b, MOD;
	static long ans;
	static int[] bugsPerLine;
	static int[][] ch = new int[1100][1100];

	public static void main(String[] args) throws IOException {
		 int[] l = readIntArray();
		 n = l[0];
		 m = l[1];
		 b = l[2];
		 MOD = l[3];
		 bugsPerLine = readIntArray();

//		n = 500;
//		m = 500;
//		b = 500;
//		MOD = 100000001;
//		bugsPerLine = new int[n];
//		for (int i = 0; i < n; i++) {
//			bugsPerLine[i] = i;
//		}

		long s = System.currentTimeMillis();

		int[][] last = new int[m + 1][b + 1];
		last[0][0] = 1;

		for (int i = n - 1; i >= 0; i--) {
			int[][] current = new int[m + 1][b + 1];

			for (int k = 0; k <= m; k++) {
				for (int j = 0; j <= b; j++) {
//					for (int j2 = 0; j2 <= m; j2++) {
//						if (k - j2 >= 0 && j - j2 * bugsPerLine[i] >= 0)
//							current[k][j] += last[k - j2][j - j2 * bugsPerLine[i]];
//					}

					current[k][j] += last[k][j];
					if (k - 1 >= 0 && j - bugsPerLine[i] >= 0)
						current[k][j] += current[k - 1][j - bugsPerLine[i]];
					current[k][j] %= MOD;
				}
			}

			last = current;
		}

		for (int i = 0; i < last[m].length; i++) {
			ans += last[m][i];
			ans %= MOD;
		}

		System.out.println(ans);
//		System.out.println("time:" + (System.currentTimeMillis() - s));
	}

}


#include <iostream>

using namespace std;

int n, m, b, mod;

int main()
{
    cin >> n >> m >> b >> mod;

    int fp[501][501];
    int a[501];

    //inicializazr el array en 0

    for(int i = 0; i <= 500; ++i){
        for(int j = 0; j <= 500; ++j){
            fp[i][j] = 0;
        }
    }

    //caso base

    fp[0][0] = 1;

    //hay "una" forma posible de escribir 0 lineas teniendo 0 errores totales

    //tomar valores de error

    for(int i = 1; i <= n; ++i){

        cin >> a[i];

        for(int linea = 1; linea <= m; ++linea){
            //se recorren las lineas escritas hasta llegar la total
            for(int error = 0; error + a[i] <= b; ++error){
                //la idea es incrementar el valor de las formas posibles
                //si tenemos que el nuevo programador tiene 2 de error por linea
                //entonces para fp(1,2) habra 1 posibilidad mas
                //para fp(2,4) tambien (fp(3,6) igual)
                //pero tambien habra una posibilidad mas para f(1,3)
                //y f(1,4), f(1,5) etc hasta que se alcance f(1, b)
                fp[linea][error + a[i]] += (fp[linea-1][error])%mod;
            }
        }
    }

    int resultado = 0;

    for(int i = 0; i <= b; ++i){
        resultado+=fp[m][i];
        //se sumando todas las fomas posibles de escribir m lineas con i errores
    }

    cout << resultado;

    return 0;
}


#include <iostream>

using namespace std;

int n, m, b, mod;

int main()
{
    cin >> n >> m >> b >> mod;

    int fp[501][501];
    int a[501];

    //inicializazr el array en 0

    for(int i = 0; i <= 500; ++i){
        for(int j = 0; j <= 500; ++j){
            fp[i][j] = 0;
        }
    }

    //caso base

    fp[0][0] = 1;

    //hay "una" forma posible de escribir 0 lineas teniendo 0 errores totales

    //tomar valores de error

    for(int i = 1; i <= n; ++i){

        cin >> a[i];

        for(int linea = 1; linea <= m; ++linea){
            //se recorren las lineas escritas hasta llegar la total
            for(int error = 0; error + a[i] <= b; ++error){
                //la idea es incrementar el valor de las formas posibles
                //si tenemos que el nuevo programador tiene 2 de error por linea
                //entonces para fp(1,2) habra 1 posibilidad mas
                //para fp(2,4) tambien (fp(3,6) igual)
                //pero tambien habra una posibilidad mas para f(1,3)
                //y f(1,4), f(1,5) etc hasta que se alcance f(1, b)
                fp[linea][error + a[i]] += (fp[linea-1][error])%mod;
            }
        }
    }

    int resultado = 0;

    for(int i = 0; i <= b; ++i){
        resultado+=fp[m][i]%mod;
        //se sumando todas las fomas posibles de escribir m lineas con i errores
    }

    cout << resultado%mod;

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int n, m, b, mod;
vector<int> a;
vector<vector<vector<int > > > z;

int dp(int i, int j, int k)
{
    if(k < 0) return 0;
    if(j == 0 && k >= 0) return 1;
    if(i == 0) return 0;
    if(z[i][j][k] != -1) return z[i][j][k];
    int temp = 0;
    for(int r = 0; r <= j; ++r){
        temp += dp(i-1,j-r,k-r*a[i]);
        temp %= mod;
    }
    return z[i][j][k] = temp;
}

int main()
{

    cin >> n >> m >> b >> mod;
    ++n; ++m; ++b;
    a.resize(n);
    z.resize(n, vector<vector<int> > (m, vector<int> (b, -1)));

    for(int i = 1; i < n; ++i){
        cin >> a[i];
    }

    cout << dp(n-1,m-1,b-1);

    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;

int dp[501][501];

int main() {
  int n, m, b, mod;
  cin >> n >> m >> b >> mod;
  int a[501];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int t = 1; t <= n; t++) {
    for (int i = 1; i <= m; i++) {
      for (int j = a[t]; j <= b; j++) {
        dp[i][j] += dp[i-1][j - a[t]];
        dp[i][j] %= mod;
      }
    }
  }
  int sum = 0;
  for (int i = 0; i <= b; i++) {
    sum += dp[m][i];
    sum %= mod;
  }
  cout << sum << endl;
}


#include <iostream>
#include <vector>

using namespace std;

int n, m, b, mod;
vector<int> a;
vector<vector<vector<int > > > z;

int dp(int i, int j, int k)
{
    if(k < 0) return 0;
    if(j == 0 && k == 0) return 1;
    if(i == 0) return 0;
    if(z[i][j][k] != -1) return z[i][j][k];
    int temp = 0;
    for(int r = 0; r <= j; ++r){
        temp += dp(i-1,j-r,k-r*a[i]);
        temp %= mod;
    }
    return z[i][j][k] = temp;
}

int main()
{

    cin >> n >> m >> b >> mod;
    ++n; ++m; ++b;
    a.resize(n);
    z.resize(n, vector<vector<int> > (m, vector<int> (b, -1)));

    for(int i = 1; i < n; ++i){
        cin >> a[i];
    }

    cout << dp(n-1,m-1,b-1);

    return 0;
}


#include <iostream>
#include <stdint.h>

using namespace std;

int n, m, b, mod;

int main()
{
    cin >> n >> m >> b >> mod;

    int64_t fp[501][501];
    int a[501];

    //inicializazr el array en 0

    for(int i = 0; i <= 500; ++i){
        for(int j = 0; j <= 500; ++j){
            fp[i][j] = 0;
        }
    }

    //caso base

    fp[0][0] = 1;

    //hay "una" forma posible de escribir 0 lineas teniendo 0 errores totales

    //tomar valores de error

    for(int i = 1; i <= n; ++i){

        cin >> a[i];

        for(int linea = 1; linea <= m; ++linea){
            //se recorren las lineas escritas hasta llegar la total
            for(int error = 0; error + a[i] <= b; ++error){
                //la idea es incrementar el valor de las formas posibles
                //si tenemos que el nuevo programador tiene 2 de error por linea
                //entonces para fp(1,2) habra 1 posibilidad mas
                //para fp(2,4) tambien (fp(3,6) igual)
                //pero tambien habra una posibilidad mas para f(1,3)
                //y f(1,4), f(1,5) etc hasta que se alcance f(1, b)
                fp[linea][error + a[i]] += (fp[linea-1][error])%mod;
            }
        }
    }

    int64_t resultado = 0;

    for(int i = 0; i <= b; ++i){
        resultado+=fp[m][i]%mod;
        //se sumando todas las fomas posibles de escribir m lineas con i errores
    }

    cout << resultado%mod;

    return 0;
}


#include <iostream>

using namespace std;

int n, m, b, mod;

int main()
{
    cin >> n >> m >> b >> mod;

    int fp[501][501];
    int a[501];

    //inicializazr el array en 0

    for(int i = 0; i <= 500; ++i){
        for(int j = 0; j <= 500; ++j){
            fp[i][j] = 0;
        }
    }

    //caso base

    fp[0][0] = 1;

    //hay "una" forma posible de escribir 0 lineas teniendo 0 errores totales

    //tomar valores de error

    for(int i = 1; i <= n; ++i){

        cin >> a[i];

        for(int linea = 1; linea <= m; ++linea){
            //se recorren las lineas escritas hasta llegar la total
            for(int error = 0; error + a[i] <= b; ++error){
                //la idea es incrementar el valor de las formas posibles
                //si tenemos que el nuevo programador tiene 2 de error por linea
                //entonces para fp(1,2) habra 1 posibilidad mas
                //para fp(2,4) tambien (fp(3,6) igual)
                //pero tambien habra una posibilidad mas para f(1,3)
                //y f(1,4), f(1,5) etc hasta que se alcance f(1, b)
                fp[linea][error + a[i]] += (fp[linea-1][error])%mod;
            }
        }
    }

    int resultado = 0;

    for(int i = 0; i <= b; ++i){
        resultado+=fp[m][i]%mod;
        //se sumando todas las fomas posibles de escribir m lineas con i errores
    }

    cout << resultado;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
const int N = 502;
short int n,m,b,ara[N];
int dp[2][N][N],mod;
inline int call(short int pos,short int line,short int bug,short int id)
{
    if(pos == n){
        return dp[pos&1][line][bug] = (line == 0 and bug >= 0);
    }
    if(id == 1)return dp[pos&1][line][bug];

    int ret = call(pos + 1,line,bug,1 - id);
    if(bug - ara[pos] >= 0 and line - 1 >= 0){
        ret += call(pos,line - 1,bug - ara[pos],1 - id);
        if(ret >= mod)ret = ret - mod;
    }
    return dp[pos&1][line][bug] = ret;
}
int main()
{
    cin >> n >> m >> b >> mod;
    for(int i = 0;i < n;i++)cin >> ara[i];

    for(int pos = n;pos >= 0;pos--){
        for(int bug = 0;bug <= b;bug++){
            for(int line = 0;line <= m;line++){
                call(pos,line,bug,0);
            }
        }
    }
    cout << call(0,m,b,0) << "\n";
}


#include<bits/stdc++.h>

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
const int N = 502;
int n,m,b,mod,ara[N];
int dp[2][N][N];
inline int call(int pos,int line,int bug,int id)
{
    if(pos == n){
        return dp[pos&1][line][bug] = (line == 0 and bug >= 0);
    }
    if(id == 1 and dp[pos&1][line][bug] != -1)return dp[pos&1][line][bug];

    int ret = call(pos + 1,line,bug,1 - id);
    if(bug - ara[pos] >= 0 and line - 1 >= 0)ret += call(pos,line - 1,bug - ara[pos],1 - id);
    if(ret >= mod)ret = ret - mod;
    return dp[pos&1][line][bug] = ret;
}
int main()
{
    MEM(dp,-1);
    cin >> n >> m >> b >> mod;
    for(int i = 0;i < n;i++)cin >> ara[i];

    for(register int pos = n;pos >= 0;pos--){
        for(register int bug = 0;bug <= b;bug++){
            for(register int line = 0;line <= m;line++){
                call(pos,line,bug,0);
            }
        }
    }
    cout << call(0,m,b,0) << "\n";
}


#include<bits/stdc++.h>

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
const int N = 502;
int n,m,b,mod,ara[N];
int dp[2][N][N];
inline int call(int pos,int line,int bug,int id)
{
    if(pos == n){
        return dp[pos&1][line][bug] = (line == 0 and bug >= 0);
    }
    if(id == 1)return dp[pos&1][line][bug];

    int ret = call(pos + 1,line,bug,1 - id);
    if(line - 1 >= 0 and bug - ara[pos] >= 0){
        ret += call(pos,line - 1,bug - ara[pos],1 - id);
        if(ret >= mod)ret = ret - mod;
    }
    return dp[pos&1][line][bug] = ret;
}
int main()
{
    cin >> n >> m >> b >> mod;
    for(int i = 0;i < n;i++)cin >> ara[i];

    for(int pos = n;pos >= 0;pos--){
        for(int bug = 0;bug <= b;bug++){
            for(int line = 0;line <= m;line++){
                call(pos,line,bug,0);
            }
        }
    }
    cout << call(0,m,b,0) << "\n";
}


#include<bits/stdc++.h>

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
const int N = 502;
int n,m,b,mod,ara[N];
int dp[2][N][N];
inline int call(int pos,int line,int bug,int id)
{
    if(pos == n){
        return dp[pos&1][line][bug] = (line == 0 and bug >= 0);
    }
    if(id == 1)return dp[pos&1][line][bug];

    int ret = call(pos + 1,line,bug,1 - id);
    if(bug - ara[pos] >= 0 and line - 1 >= 0)ret += call(pos,line - 1,bug - ara[pos],1 - id);
    if(ret >= mod)ret = ret - mod;
    return dp[pos&1][line][bug] = ret;
}
int main()
{
    cin >> n >> m >> b >> mod;
    for(int i = 0;i < n;i++)cin >> ara[i];

    for(int pos = n;pos >= 0;pos--){
        for(int bug = 0;bug <= b;bug++){
            for(int line = 0;line <= m;line++){
                call(pos,line,bug,0);
            }
        }
    }
    cout << call(0,m,b,0) << "\n";
}


#include<bits/stdc++.h>

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
const int N = 502;
int n,m,b,mod,ara[N];
int dp[2][N][N];
inline int call(int pos,int line,int bug,int id)
{
    if(pos == n){
        return dp[pos&1][line][bug] = (line == 0 and bug >= 0);
    }
    if(id == 1)return dp[pos&1][line][bug];

    int ret = call(pos + 1,line,bug,id ^ 1);
    if(bug - ara[pos] >= 0 and line - 1 >= 0){
        ret += call(pos,line - 1,bug - ara[pos],id ^ 1);
        if(ret >= mod)ret = ret - mod;
    }
    return dp[pos&1][line][bug] = ret;
}
int main()
{
    cin >> n >> m >> b >> mod;
    for(int i = 0;i < n;i++)cin >> ara[i];

    for(int pos = n;pos >= 0;pos--){
        for(int bug = 0;bug <= b;bug++){
            for(int line = 0;line <= m;line++){
                call(pos,line,bug,0);
            }
        }
    }
    cout << call(0,m,b,0) << "\n";
}


#include<bits/stdc++.h>

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
const int N = 502;
int n,m,b,mod,ara[N];
int dp[2][N][N];
inline int call(int pos,int line,int bug,int id)
{
    if(pos == n){
        return dp[pos&1][line][bug] = (line == 0 and bug >= 0);
    }
    if(id == 1)return dp[pos&1][line][bug];

    int ret = call(pos + 1,line,bug,1 - id);
    if(line - 1 >= 0 and bug - ara[pos] >= 0){
        ret += call(pos,line - 1,bug - ara[pos],1 - id);
    }
    if(ret >= mod)ret = ret - mod;
    return dp[pos&1][line][bug] = ret;
}
int main()
{
    cin >> n >> m >> b >> mod;
    for(int i = 0;i < n;i++)cin >> ara[i];

    for(int pos = n;pos >= 0;pos--){
        for(int bug = 0;bug <= b;bug++){
            for(int line = 0;line <= m;line++){
                call(pos,line,bug,0);
            }
        }
    }
    cout << call(0,m,b,0) << "\n";
}


#include<bits/stdc++.h>

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
const int N = 502;
int n,m,b,mod,ara[N];
int dp[2][N][N];
inline int call(int pos,int line,int bug,int id)
{
    if(pos == n){
        return dp[pos&1][line][bug] = (line == 0 and bug >= 0);
    }
    if(id == 1)return dp[pos&1][line][bug];

    int ret = call(pos + 1,line,bug,1 - id);
    if(bug - ara[pos] >= 0 and line - 1 >= 0){
        ret += call(pos,line - 1,bug - ara[pos],1 - id);
        if(ret >= mod)ret = ret - mod;
    }
    return dp[pos&1][line][bug] = ret;
}
int main()
{
    cin >> n >> m >> b >> mod;
    for(int i = 0;i < n;i++)cin >> ara[i];

    for(int pos = n;pos >= 0;pos--){
        for(int bug = 0;bug <= b;bug++){
            for(int line = 0;line <= m;line++){
                call(pos,line,bug,0);
            }
        }
    }
    cout << call(0,m,b,0) << "\n";
}


#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <assert.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <queue>

using namespace std;

#define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for(int i = int(n); i >= int(x); --i)
#define file ""
#define pb push_back
#define F first
#define S second
#define mk_pr make_pair
#define _bits __builtin_popcount

typedef long long ll;
typedef pair <int, int> PII;
typedef const int c_i;

const int maxn = 512;
const int INF = 1e9 + 9;

int n, m, b, base;
int a[maxn];

ll d[maxn][maxn][maxn];

int main() {
#ifdef machine42
	freopen(file"in", "r", stdin);
	freopen(file"out", "w", stdout);
#endif
	scanf("%d %d %d %d", &n, &m, &b, &base);
	forn(i, 1, n)
		scanf("%d", &a[i]);

	d[0][0][0] = 1;
	forn(pref, 1, n) {
		forn(sum, 0, m) {
			forn(e, 0, b) {
				int max_c = min(sum, e / a[pref]);
				forn(c, 0, max_c)
					d[pref][sum][e] = (d[pref][sum][e] + d[pref - 1][sum - c][e - c * a[pref]]) % base;
			}
		}
	}

	ll ans = 0;
	forn(e, 0, b)
		ans = (ans + d[n][m][e]) % base;
	printf("%I64d\n", ans);

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <assert.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <queue>

using namespace std;

#define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for(int i = int(n); i >= int(x); --i)
#define file ""
#define pb push_back
#define F first
#define S second
#define mk_pr make_pair
#define _bits __builtin_popcount

typedef long long ll;
typedef pair <int, int> PII;
typedef const int c_i;

const int maxn = 501;
const int INF = 1e9 + 9;

int n, m, b, base;
int a[maxn];

int d[2][maxn][maxn];
int s[2][maxn][maxn];

int main() {
#ifdef machine42
	freopen(file"in", "r", stdin);
	freopen(file"out", "w", stdout);
#endif
	scanf("%d %d %d %d", &n, &m, &b, &base);
	forn(i, 1, n)
		scanf("%d", &a[i]);

	d[0][0][0] = 1;
	forn(pref, 1, n) {
		int p = pref & 1;
		forn(sum, 0, m) {
			forn(e, 0, b) {
				int max_c = min(sum, e / a[pref]);
				d[p][sum][e] = (d[p ^ 1][sum][e] + d[p][sum - 1][e - a[pref]]) % base;
			}
		}
	}

	ll ans = 0;
	forn(e, 0, b)
		ans = (ans + d[n & 1][m][e]) % base;
	printf("%I64d\n", ans);

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <assert.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <queue>

using namespace std;

#define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for(int i = int(n); i >= int(x); --i)
#define file ""
#define pb push_back
#define F first
#define S second
#define mk_pr make_pair
#define _bits __builtin_popcount

typedef long long ll;
typedef pair <int, int> PII;
typedef const int c_i;

const int maxn = 501;
const int INF = 1e9 + 9;

int n, m, b, base;
int a[maxn];

ll d[2][maxn][maxn];

int main() {
#ifdef machine42
	freopen(file"in", "r", stdin);
	freopen(file"out", "w", stdout);
#endif
	scanf("%d %d %d %d", &n, &m, &b, &base);
	forn(i, 1, n)
		scanf("%d", &a[i]);

	d[0][0][0] = 1;
	forn(pref, 1, n) {
		int p = pref & 1;
		forn(sum, 0, m) {
			forn(e, 0, b) {
				int max_c = min(sum, e / a[pref]);
				d[p][sum][e] = d[p ^ 1][sum][e];
				if (sum && e >= a[pref])
					d[p][sum][e] = (d[p][sum][e] + d[p][sum - 1][e - a[pref]]) % base;
			}
		}
	}

	ll ans = 0;
	forn(e, 0, b)
		ans = (ans + d[n & 1][m][e]) % base;
	printf("%I64d\n", ans);

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <assert.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <queue>

using namespace std;

#define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for(int i = int(n); i >= int(x); --i)
#define file ""
#define pb push_back
#define F first
#define S second
#define mk_pr make_pair
#define _bits __builtin_popcount

typedef long long ll;
typedef pair <int, int> PII;
typedef const int c_i;

const int maxn = 301;
const int INF = 1e9 + 9;

int n, m, b, base;
int a[maxn];

int d[maxn][maxn][maxn];

int main() {
#ifdef machine42
	freopen(file"in", "r", stdin);
	freopen(file"out", "w", stdout);
#endif
	scanf("%d %d %d %d", &n, &m, &b, &base);
	forn(i, 1, n)
		scanf("%d", &a[i]);

	d[0][0][0] = 1;
	forn(pref, 1, n) {
		forn(sum, 0, m) {
			forn(e, 0, b) {
				int max_c = min(sum, e / a[pref]);
				forn(c, 0, max_c)
					d[pref][sum][e] = (d[pref][sum][e] + d[pref - 1][sum - c][e - c * a[pref]]) % base;
			}
		}
	}

	ll ans = 0;
	forn(e, 0, b)
		ans = (ans + d[n][m][e]) % base;
	printf("%I64d\n", ans);

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <assert.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <queue>

using namespace std;

#define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for(int i = int(n); i >= int(x); --i)
#define file ""
#define pb push_back
#define F first
#define S second
#define mk_pr make_pair
#define _bits __builtin_popcount

typedef long long ll;
typedef pair <int, int> PII;
typedef const int c_i;

const int maxn = 501;
const int INF = 1e9 + 9;

int n, m, b, base;
int a[maxn];

int d[maxn][maxn][maxn];

int main() {
#ifdef machine42
	freopen(file"in", "r", stdin);
	freopen(file"out", "w", stdout);
#endif
	scanf("%d %d %d %d", &n, &m, &b, &base);
	forn(i, 1, n)
		scanf("%d", &a[i]);

	d[0][0][0] = 1;
	forn(pref, 1, n) {
		forn(sum, 0, m) {
			forn(e, 0, b) {
				int max_c = min(sum, e / a[pref]);
				forn(c, 0, max_c)
					d[pref][sum][e] = (d[pref][sum][e] + d[pref - 1][sum - c][e - c * a[pref]]) % base;
			}
		}
	}

	ll ans = 0;
	forn(e, 0, b)
		ans = (ans + d[n][m][e]) % base;
	printf("%I64d\n", ans);

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <assert.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <queue>

using namespace std;

#define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for(int i = int(n); i >= int(x); --i)
#define file ""
#define pb push_back
#define F first
#define S second
#define mk_pr make_pair
#define _bits __builtin_popcount

typedef long long ll;
typedef pair <int, int> PII;
typedef const int c_i;

const int maxn = 501;
const int INF = 1e9 + 9;

int n, m, b, base;
int a[maxn];

ll d[2][maxn][maxn];

int main() {
#ifdef machine42
	freopen(file"in", "r", stdin);
	freopen(file"out", "w", stdout);
#endif
	scanf("%d %d %d %d", &n, &m, &b, &base);
	forn(i, 1, n)
		scanf("%d", &a[i]);

	d[0][0][0] = 1;
	forn(pref, 1, n) {
		int p = pref & 1;
		forn(sum, 0, m) {
			forn(e, 0, b) {
				int max_c = min(sum, e / a[pref]);
				d[p][sum][e] = (d[p ^ 1][sum][e] + d[p][sum - 1][e - a[pref]]) % base;
			}
		}
	}

	ll ans = 0;
	forn(e, 0, b)
		ans = (ans + d[n & 1][m][e]) % base;
	printf("%I64d\n", ans);

    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <assert.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <queue>

using namespace std;

#define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for(int i = int(n); i >= int(x); --i)
#define file ""
#define pb push_back
#define F first
#define S second
#define mk_pr make_pair
#define _bits __builtin_popcount

typedef long long ll;
typedef pair <int, int> PII;
typedef const int c_i;

const int maxn = 501;
const int INF = 1e9 + 9;

int n, m, b, base;
int a[maxn];

int d[2][maxn][maxn];

int main() {
#ifdef machine42
	freopen(file"in", "r", stdin);
	freopen(file"out", "w", stdout);
#endif
	scanf("%d %d %d %d", &n, &m, &b, &base);
	forn(i, 1, n)
		scanf("%d", &a[i]);

	d[0][0][0] = 1;
	forn(pref, 1, n) {
		int p = pref & 1;
		forn(sum, 0, m) {
			forn(e, 0, b) {
				int max_c = min(sum, e / a[pref]);
				d[p][sum][e] = 0;
				forn(c, 0, max_c)
					d[p][sum][e] = (d[p][sum][e] + d[p ^ 1][sum - c][e - c * a[pref]]) % base;
			}
		}
	}

	ll ans = 0;
	forn(e, 0, b)
		ans = (ans + d[n & 1][m][e]) % base;
	printf("%I64d\n", ans);

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>

using namespace std;

int N,M,B,mod;
int A[505];
ll dp[505][505][505];

ll solve(int n, int m , int b)
{
    if(n==N && m==M)
      return 1;

     if(n>N)
        return 0;

    if(dp[n][m][b]!=-1)
        return dp[n][m][b];

    ll ans=0;

    for(int i=0;i<=M;i++)
    {
        if(m+i<=M && b+A[n]*i<=B)
            ans=(ans + solve(n+1,m+i,b+A[n]*i))%mod;
    }

    return dp[n][m][b] = ans%mod;

}

main()
{
 cin>>N>>M>>B>>mod;
 memset(dp,-1,sizeof(dp));
 for(int i=0;i<N;i++)
 {
   cin>>A[i];
 }

 cout<<solve(0,0,0);
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>

using namespace std;

int N,M,B,mod;
int A[505];
int dp[505][505][505];

ll solve(int n, int m , int b)
{
    if(n==N && m==M)
      return 1;

     if(n>N)
        return 0;

    if(dp[n][m][b]!=-1)
        return dp[n][m][b];

    ll ans=0;

    for(int i=0;i<=M;i++)
    {
        if(m+i<=M && b+A[n]*i<=B)
            ans=(ans + solve(n+1,m+i,b+A[n]*i))%mod;
    }

    return dp[n][m][b] = ans%mod;

}

main()
{
 cin>>N>>M>>B>>mod;
 memset(dp,-1,sizeof(dp));
 for(int i=0;i<N;i++)
 {
   cin>>A[i];
 }

 cout<<solve(0,0,0);
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>

using namespace std;

int N,M,B,mod;
int A[500];
int dp[500][500][500];

int solve(int n, int m , int b)
{
    if(n==N && m==M)
      return 1;

     if(n>N)
        return 0;

    if(dp[n][m][b]!=-1)
        return dp[n][m][b];

    ll ans=0;

    for(int i=0;i<=M;i++)
    {
        if(m+i<=M && b+A[n]*i<=B)
            ans=(ans + solve(n+1,m+i,b+A[n]*i))%mod;
    }

    return dp[n][m][b] = ans%mod;
}

main()
{
 cin>>N>>M>>B>>mod;
 //int dp[N][M][B];
 memset(dp,-1,sizeof(dp));
 for(int i=0;i<N;i++)
 {
   cin>>A[i];
 }

 cout<<solve(0,0,0);
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;

int dp[505][505];
main()
{
 std::ios::sync_with_stdio(false);

 int n,m,b,mod;
 cin>>n>>m>>b>>mod;

 int A[505];
 for(int i=1;i<=n;i++)
 cin>>A[i];

 dp[0][0]=1;

 for(int i=1;i<=n;i++)
  for(int j=1;j<=m;j++)
   for(int k=0;k<=b;k++)
  {
      if(k-A[i]>=0)
       {dp[j][k]+= dp[j-1][k-A[i]];
        while(dp[j][k]>=mod)
            dp[j][k]-=mod;
       }
  }

   ll ans=0;
   for(int i=0;i<=b;i++)
   {
       ans+=dp[m][i];
       while(ans>=mod)ans-=mod;

   }

    cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>

using namespace std;

int N,M,B,mod;
int A[500];
int dp[55][500][500];

int solve(int n, int m , int b)
{
    if(n==N && m==M)
      return 1;

     if(n>N)
        return 0;

    if(dp[n][m][b]!=-1)
        return dp[n][m][b];

    ll ans=0;

    for(int i=0;i<=M;i++)
    {
        if(m+i<=M && b+A[n]*i<=B)
            ans=(ans + solve(n+1,m+i,b+A[n]*i))%mod;
    }

    return dp[n][m][b] = ans%mod;
}

main()
{
 cin>>N>>M>>B>>mod;
 //int dp[N][M][B];
 memset(dp,-1,sizeof(dp));
 for(int i=0;i<N;i++)
 {
   cin>>A[i];
 }

 cout<<solve(0,0,0);
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;

int dp[505][505];
main()
{
 std::ios::sync_with_stdio(false);

 int n,m,b,mod;
 cin>>n>>m>>b>>mod;

 int A[505];
 for(int i=1;i<=n;i++)
 cin>>A[i];

 dp[0][0]=1;

 for(int i=1;i<=n;i++)
  for(int j=1;j<=m;j++)
   for(int k=0;k<=b;k++)
  {
      if(k-A[i]>=0)
       {dp[k][j]+= dp[k-A[i]][j-1];
        while(dp[k][j]>=mod)
            dp[k][j]-=mod;
       }
  }

   ll ans=0;
   for(int i=0;i<=b;i++)
   {
       ans+=dp[i][m];
       while(ans>=mod)ans-=mod;

   }

    cout<<ans;
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX 507
int n,m,b,mod, resp;
int a[MAX];
int dp[MAX][MAX];

void init() {
     memset (dp, 0, sizeof(dp));
     }

int main ( ) {
    while (~scanf ("%d %d %d %d" , &n , &m , &b , &mod )) {
        init();
        dp[0][0] = 10;
        resp = 10;
        for (int i = 1 ; i <= n ; i++) { scanf ( "%d" , &a[i] );}
        for (int i = 1 ; i <= n ; i++) {
            for (int j = 1 ; j <= m ; j++) {
                for (int k = 0; k <= b ; k++) {
                    if (k >= a[i]) {
                        dp[j][k] += dp[j-1][k-a[i]];
                        dp[j][k] %= mod;
                    }
                }
            }
        }

        for (int k = 0 ; k <= b ; k++) {
            resp += dp[m][k];
            resp %= mod;
        }

        printf ("%d\n", resp);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 507
int n,m,b,mod, resp;
int a[MAX];
int dp[MAX][MAX];

void init() {
     memset (dp, 0, sizeof(dp));
     }

int main ( ) {
    while (~scanf ("%d %d %d %d" , &n , &m , &b , &mod )) {
        init();
        dp[0][0] = 1;
        resp = 0;
        for (int i = 1 ; i <= n ; i++) { scanf ( "%d" , &a[i] );}
        for (int i = 1 ; i <= n ; i++) {
            for (int j = 1 ; j <= m ; j++) {
                for (int k = 0; k <= b ; k++) {
                    if (k >= a[i]) {
                        dp[j][k] += dp[j-1][k-a[i]];
                        dp[j][k] %= mod;
                    }
                }
            }
        }

        for (int k = 0 ; k <= b ; k++) {
            resp += dp[m][k];
            resp %= mod;
        }

        printf ("%d\n", resp);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX 507
int n,m,b,mod, resp;
int a[MAX];
int dp[MAX][MAX];

void init() {
     memset ( dp , 0 , sizeof ( dp ));
     }

int main ( ) {
    while (~scanf ("%d %d %d %d" , &n , &m , &b , &mod )) {
        init();
        dp[0][0] = 1;
        resp = 0;
        for ( int i = 1 ; i <= n ; i++ ) { scanf ( "%d" , &a[i] );}
        for ( int i = 1 ; i <= n ; i++ )
            for ( int j = 1 ; j <= m ; j++ )
                for ( int k = 0; k <= b ; k++ )
                    if ( k >= a[i] ) {
                        dp[j][k] += dp[j-1][k-a[i]];
                        dp[j][k] %= mod;
                    }

        for ( int k = 0 ; k <= b ; k++ ) {
            resp += dp[m][k];
            resp %= mod + 1;
        }

        printf ( "%d\n" , resp );
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX 507
int n,m,b,mod, resp;
int a[MAX];
int dp[MAX][MAX];

void init() {
     memset (dp, 0, sizeof(dp));
     }

int main ( ) {
    while (~scanf ("%d %d %d %d" , &n , &m , &b , &mod )) {
        init();
        dp[0][0] = 1;
        resp = 1;
        for (int i = 1 ; i <= n ; i++) { scanf ( "%d" , &a[i] );}
        for (int i = 1 ; i <= n ; i++) {
            for (int j = 1 ; j <= m ; j++) {
                for (int k = 0; k <= b ; k++) {
                    if (k >= a[i]) {
                        dp[j][k] += dp[j-1][k-a[i]];
                        dp[j][k] %= mod;
                    }
                }
            }
        }

        for (int k = 0 ; k <= b ; k++) {
            resp += dp[m][k];
            resp %= mod;
        }

        printf ("%d\n", resp);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX 507
int n,m,b,mod, resp;
int a[MAX];
int dp[MAX][MAX];

void init() {
     memset (dp, 0, sizeof(dp));
     }

int main ( ) {
    while (~scanf ("%d %d %d %d" , &n , &m , &b , &mod )) {
        init();
        dp[0][0] = 1;
        resp = 0;
        for (int i = 1 ; i <= n ; i++) { scanf ( "%d" , &a[i] );}
        for (int i = 1 ; i <= n ; i++) {
            for (int j = 1 ; j <= m ; j++) {
                for (int k = 0; k <= b ; k++) {
                    if (k >= a[i]) {
                        dp[j][k] += dp[j-1][k-a[i]];
                        dp[j][k] %= mod -1;
                    }
                }
            }
        }

        for (int k = 0 ; k <= b ; k++) {
            resp += dp[m][k];
            resp %= mod;
        }

        printf ("%d\n", resp);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX 507
int n,m,b,mod, resp;
int a[MAX];
int dp[MAX][MAX];

void init() {
     memset (dp, 0, sizeof(dp));
     }

int main ( ) {
    while (~scanf ("%d %d %d %d" , &n , &m , &b , &mod )) {
        init();
        dp[0][0] = 1;
        resp = 0;
        for (int i = 1 ; i <= n ; i++) { scanf ( "%d" , &a[i] );}
        for (int i = 1 ; i <= n ; i++) {
            for (int j = 1 ; j <= m ; j++) {
                for (int k = 0; k <= b ; k++) {
                    if (k >= a[i]) {
                        dp[j][k] += dp[j+1][k-a[i]];
                        dp[j][k] %= mod;
                    }
                }
            }
        }

        for (int k = 0 ; k <= b ; k++) {
            resp += dp[m][k];
            resp %= mod;
        }

        printf ("%d\n", resp);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX 507
int n,m,b,mod, resp;
int a[MAX];
int dp[MAX][MAX];

void init() {
     memset (dp, 0, sizeof(dp));
     }

int main ( ) {
    while (~scanf ("%d %d %d %d" , &n , &m , &b , &mod )) {
        init();
        dp[0][0] = 1;
        resp = 0;
        for (int i = 1 ; i <= n ; i++) { scanf ( "%d" , &a[i] );}
        for (int i = 1 ; i <= n ; i++) {
            for (int j = 1 ; j <= m ; j++) {
                for (int k = 0; k <= b ; k++) {
                    if (k >= a[i]) {
                        dp[j][k] += dp[j-1][k-a[i]];
                        dp[j][k] %= mod;
                    }
                }
            }
        }

        for (int k = 0 ; k <= b ; k++) {
            resp += dp[m][k];
            resp %= mod;
        }

        printf ("%d\n", resp);
    }
    return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
// struct H{
// 	int a,b,c;
// };
// bool operator <(const H& x, const H& y) {
//     return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
// }
// map<H,int> dp;
int dp[2][501][501];
int a[600];

int modulo(int n,int mod){
	if(n>mod) return n-mod;
	return n;
}

int main() {
	int n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	// H h={0,0,0};
	dp[0][0][0]=1;
	int cur=0,prev=0;
	for (int i = 1; i <=n ; ++i)
	{
		cur=i%2;
		prev=(i+1)%2;
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				dp[cur][j][k]=0;
				for (int p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					// h={i-1,p,k-a[i]*(j-p)};
					// H ht={i,j,k};
					dp[cur][j][k]= modulo(dp[cur][j][k]+ dp[prev][p][k-a[i]*(j-p)],mod);
				}
			}
		}
	}
	int res=0;
	for (int i = 0; i <=b; ++i)
	{
		// H ht={n,m,i};
		res=modulo(res+dp[cur][m][i],mod);
	}
	cout<<res%mod<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;

ll dp[501][501][501];
ll a[600];
int main() {
	ll n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	dp[0][0][0]=1;
	for (int i = 1; i <=n ; ++i)
	{
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				for (int p = 0; p <=j  ; ++p)
				{
					if(k-a[i]*(j-p)<0) continue;
					// cout<<"p "<<p<<endl;
					dp[i][j][k]+=dp[i-1][p][ k-a[i]*(j-p)];
				}
			}
		}
	}
	ll res=0;
	for (int i = 0; i <=b; ++i)
	{
		res=(res+dp[n][m][i])%mod;
	}
	cout<<res<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
// struct H{
// 	ll a,b,c;
// };
// bool operator <(const H& x, const H& y) {
//     return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
// }
// map<H,ll> dp;
ll dp[2][501][501];
ll a[600];

ll modulo(ll n,ll mod){
	if(n>mod) return n-mod;
	return n;
}

int main() {
	ll n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (ll i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	// H h={0,0,0};
	dp[0][0][0]=1;
	ll cur=0,prev=0;
	for (ll i = 1; i <=n ; ++i)
	{
		cur=i%2;
		prev=(i+1)%2;
		for (ll j = 0; j <=m ; ++j)
		{
			for (ll k = 0; k <=b ; ++k)
			{
				dp[cur][j][k]=0;
				for (ll p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					// h={i-1,p,k-a[i]*(j-p)};
					// H ht={i,j,k};
					dp[cur][j][k]= dp[cur][j][k]+ dp[prev][p][k-a[i]*(j-p)];
				}
			}
		}
	}
	ll res=0;
	for (ll i = 0; i <=b; ++i)
	{
		// H ht={n,m,i};
		res=modulo(res+dp[cur][m][i],mod);
	}
	cout<<res%mod<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
// struct H{
// 	int a,b,c;
// };
// bool operator <(const H& x, const H& y) {
//     return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
// }
// map<H,ll> dp;
 int dp[2][501][501];
int a[600];
int main() {
	int n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	// H h={0,0,0};
	dp[0][0][0]=1;
	int cur,prev;
	for (int i = 1; i <=n ; ++i)
	{
		cur=i%2;
		prev=(i-1)%2;
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				dp[cur][j][k]=0;
				for (int p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					// h={i-1,p,k-a[i]*(j-p)};
					// H ht={i,j,k};
					dp[cur][j][k]+=dp[prev][p][k-a[i]*(j-p)];
				}
			}
		}
	}
	int res=0;
	for (int i = 0; i <=b; ++i)
	{
		// H ht={n,m,i};
		res=(res+dp[cur][m][i])%mod;
	}
	cout<<res<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
// struct H{
// 	int a,b,c;
// };
// bool operator <(const H& x, const H& y) {
//     return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
// }
// map<H,int> dp;
int dp[2][501][501];
int a[600];

int modulo(int n,int mod){
	if(n>mod) return n-mod;
	return n;
}

int main() {
	int n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	// H h={0,0,0};
	dp[0][0][0]=1;
	int cur=0,prev=0;
	for (int i = 1; i <=n ; ++i)
	{
		cur=i%2;
		prev=(i+1)%2;
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				dp[cur][j][k]=dp[prev][j][k];
				if(j>0 && k-a[i]>=0)
					dp[cur][j][k]= modulo(dp[cur][j][k]+ dp[cur][j-1][k-a[i]],mod);
			}
		}
	}
	int res=0;
	for (int i = 0; i <=b; ++i)
	{
		// H ht={n,m,i};
		res=modulo(res+dp[cur][m][i],mod);
	}
	cout<<res%mod<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
// struct H{
// 	int a,b,c;
// };
// bool operator <(const H& x, const H& y) {
//     return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
// }
// map<H,ll> dp;
 int dp[2][501][501];
int a[600];
int main() {
	int n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	// H h={0,0,0};
	dp[0][0][0]=1;
	int cur=0,prev=0;
	for (int i = 1; i <=n ; ++i)
	{
		cur=i%2;
		prev=(i+1)%2;
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				dp[cur][j][k]=0;
				for (int p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					// h={i-1,p,k-a[i]*(j-p)};
					// H ht={i,j,k};
					dp[cur][j][k]+=dp[prev][p][k-a[i]*(j-p)];
				}
			}
		}
	}
	int res=0;
	for (int i = 0; i <=b; ++i)
	{
		// H ht={n,m,i};
		res=(res+dp[cur][m][i])%mod;
	}
	cout<<res%mod<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;

ll dp[600][600][600];
ll a[600];
int main() {
	ll n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	dp[0][0][0]=1;
	for (int i = 1; i <=n ; ++i)
	{
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				for (int p = 0; p <=j  ; ++p)
				{
					if(k-a[i]*(j-p)<0) continue;
					// cout<<"p "<<p<<endl;
					dp[i][j][k]+=dp[i-1][p][ k-a[i]*(j-p)];
				}
			}
		}
	}
	ll res=0;
	for (int i = 0; i <=b; ++i)
	{
		res=(res+dp[n][m][i])%mod;
	}
	cout<<res<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
// struct H{
// 	int a,b,c;
// };
// bool operator <(const H& x, const H& y) {
//     return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
// }
// map<H,ll> dp;
 int dp[2][501][501];
int a[600];
int main() {
	int n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	// H h={0,0,0};
	dp[0][0][0]=1;
	int cur=0,prev=0;
	for (int i = 1; i <=n ; ++i)
	{
		cur=i%2;
		prev=(i-1)%2;
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				dp[cur][j][k]=0;
				for (int p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					// h={i-1,p,k-a[i]*(j-p)};
					// H ht={i,j,k};
					dp[cur][j][k]+=dp[prev][p][k-a[i]*(j-p)];
				}
			}
		}
	}
	int res=0;
	for (int i = 0; i <=b; ++i)
	{
		// H ht={n,m,i};
		res=(res+dp[cur][m][i])%mod;
	}
	cout<<res<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
// struct H{
// 	ll a,b,c;
// };
// bool operator <(const H& x, const H& y) {
//     return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
// }
// map<H,ll> dp;
ll dp[2][501][501];
ll a[600];
int main() {
	ll n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (ll i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	// H h={0,0,0};
	dp[0][0][0]=1;
	ll cur=0,prev=0;
	for (ll i = 1; i <=n ; ++i)
	{
		cur=i%2;
		prev=(i+1)%2;
		for (ll j = 0; j <=m ; ++j)
		{
			for (ll k = 0; k <=b ; ++k)
			{
				dp[cur][j][k]=0;
				for (ll p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					// h={i-1,p,k-a[i]*(j-p)};
					// H ht={i,j,k};
					dp[cur][j][k]= (dp[cur][j][k]+ dp[prev][p][k-a[i]*(j-p)])%mod;
				}
			}
		}
	}
	ll res=0;
	for (ll i = 0; i <=b; ++i)
	{
		// H ht={n,m,i};
		res=(res+dp[cur][m][i])%mod;
	}
	cout<<res%mod<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
// struct H{
// 	ll a,b,c;
// };
// bool operator <(const H& x, const H& y) {
//     return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
// }
// map<H,ll> dp;
ll dp[2][501][501];
ll a[600];

ll modulo(ll n,ll mod){
	if(n>mod) return n-mod;
	return n;
}

int main() {
	ll n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (ll i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	// H h={0,0,0};
	dp[0][0][0]=1;
	ll cur=0,prev=0;
	for (ll i = 1; i <=n ; ++i)
	{
		cur=i%2;
		prev=(i+1)%2;
		for (ll j = 0; j <=m ; ++j)
		{
			for (ll k = 0; k <=b ; ++k)
			{
				dp[cur][j][k]=0;
				for (ll p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					// h={i-1,p,k-a[i]*(j-p)};
					// H ht={i,j,k};
					dp[cur][j][k]= dp[cur][j][k]+ dp[prev][p][k-a[i]*(j-p)];
				}
			}
		}
	}
	ll res=0;
	for (ll i = 0; i <=b; ++i)
	{
		// H ht={n,m,i};
		res=res+dp[cur][m][i];
	}
	cout<<res%mod<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
struct H{
	int a,b,c;
};
bool operator <(const H& x, const H& y) {
    return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
}
map<H,ll> dp;
// int dp[501][501][501];
int a[600];
int main() {
	int n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	H h={0,0,0};
	dp[h]=1;
	for (int i = 1; i <=n ; ++i)
	{
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				for (int p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					h={i-1,p,k-a[i]*(j-p)};
					H ht={i,j,k};
					dp[ht]+=dp[h];
				}
			}
		}
	}
	int res=0;
	for (int i = 0; i <=b; ++i)
	{
		H ht={n,m,i};
		res=(res+dp[ht])%mod;
	}
	cout<<res<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
// struct H{
// 	ll a,b,c;
// };
// bool operator <(const H& x, const H& y) {
//     return std::tie(x.a, x.b, x.c) < std::tie(y.a, y.b, y.c);
// }
// map<H,ll> dp;
ll dp[2][501][501];
ll a[600];

ll modulo(ll n,ll mod){
	if(n>mod) return n-mod;
	return n;
}

int main() {
	ll n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (ll i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	// H h={0,0,0};
	dp[0][0][0]=1;
	ll cur=0,prev=0;
	for (ll i = 1; i <=n ; ++i)
	{
		cur=i%2;
		prev=(i+1)%2;
		for (ll j = 0; j <=m ; ++j)
		{
			for (ll k = 0; k <=b ; ++k)
			{
				dp[cur][j][k]=0;
				for (ll p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					// h={i-1,p,k-a[i]*(j-p)};
					// H ht={i,j,k};
					dp[cur][j][k]= modulo(dp[cur][j][k]+ dp[prev][p][k-a[i]*(j-p)],mod);
				}
			}
		}
	}
	ll res=0;
	for (ll i = 0; i <=b; ++i)
	{
		// H ht={n,m,i};
		res=modulo(res+dp[cur][m][i],mod);
	}
	cout<<res%mod<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;

ll dp[510][510][510];
ll a[600];
int main() {
	ll n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	dp[0][0][0]=1;
	for (int i = 1; i <=n ; ++i)
	{
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				for (int p = 0; p <=j  ; ++p)
				{
					if(k-a[i]*(j-p)<0) continue;
					// cout<<"p "<<p<<endl;
					dp[i][j][k]+=dp[i-1][p][ k-a[i]*(j-p)];
				}
			}
		}
	}
	ll res=0;
	for (int i = 0; i <=b; ++i)
	{
		res=(res+dp[n][m][i])%mod;
	}
	cout<<res<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;

int dp[501][501][501];
int a[600];
int main() {
	ll n, m, b, mod;
	cin>>n>>m>>b>>mod;

	for (int i = 1; i <=n ; ++i)
	{
		cin>>a[i];
	}
	dp[0][0][0]=1;
	for (int i = 1; i <=n ; ++i)
	{
		for (int j = 0; j <=m ; ++j)
		{
			for (int k = 0; k <=b ; ++k)
			{
				for (int p = j; p >=0  ; --p)
				{
					if(k-a[i]*(j-p)<0) break;
					// cout<<"p "<<p<<endl;
					dp[i][j][k]+=dp[i-1][p][ k-a[i]*(j-p)];
				}
			}
		}
	}
	int res=0;
	for (int i = 0; i <=b; ++i)
	{
		res=(res+dp[n][m][i])%mod;
	}
	cout<<res<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b;
long long mod;
int a;
int cnt[MAXN];
int dp[MAXN][MAXN], dp2[MAXN][MAXN];
int c[MAXN][MAXN];

inline int Mod(int x) {
    return x >= mod ? x - (int)mod : x;
}

void precalc() {
    for (int i = 0; i <= n; ++i)
        c[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = 0; k <= j; ++k)
                c[i][j] = Mod(c[i][j] + c[i - 1][j - k]);
}

int main() {
    cin >> n >> m >> b >> mod;
    for (int i = 0; i < n; ++i)
        cin >> a, ++cnt[a];
    precalc();
    dp[0][0] = dp2[0][0] = 1;
    for (int i = 0; i < MAXN; ++i)
        if (cnt[i]) {
            for (int j = 0; j < m; ++j)
                for (int k = 0; k <= b; ++k) {
                    if (k + i <= b)
                        dp2[j + 1][k + i] = Mod(dp2[j + 1][k + i] + (int)(((long long)cnt[i] * (long long)dp[j][k]) % mod));
                }
            for (int i = 0; i <= m; ++i)
                for (int j = 0; j <= b; ++j)
                    dp[i][j] = dp2[i][j];
        }
    int sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = Mod(sum + dp[m][i]);
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b;
long long mod;
int a;
int cnt[MAXN];
int dp[MAXN][MAXN], dp2[MAXN][MAXN];
int c[MAXN][MAXN];

int Mod(int x) {
    return x >= mod ? x - (int)mod : x;
}

void precalc() {
    for (int i = 0; i <= n; ++i)
        c[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = 0; k <= j; ++k)
                c[i][j] = Mod(c[i][j] + c[i - 1][j - k]);
}

int main() {
    cin >> n >> m >> b >> mod;
    for (int i = 0; i < n; ++i)
        cin >> a, ++cnt[a];
    precalc();
    dp[0][0] = dp2[0][0] = 1;
    for (int i = 0; i < MAXN; ++i)
        if (cnt[i]) {
            for (int j = 0; j < m; ++j)
                for (int k = 0; k <= b; ++k) {
                    for (int z = 1; j + z <= m && k + i * z <= b; ++z) {
                        dp2[j + z][k + i * z] = Mod(dp2[j + z][k + i * z] + (int)((long long)c[cnt[i]][z] * (long long)dp[j][k]) % mod);
                    }
                }
            for (int i = 0; i <= m; ++i)
                for (int j = 0; j <= b; ++j)
                    dp[i][j] = dp2[i][j];
        }
    int sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = Mod(sum + dp[m][i]);
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b;
long long mod;
int a;
int cnt[MAXN];
int dp[2][MAXN][MAXN];
int c[MAXN][MAXN];

inline int Mod(int x) {
    return x >= mod ? x - (int)mod : x;
}

void precalc() {
    for (int i = 0; i <= n; ++i)
        c[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = 0; k <= j; ++k)
                c[i][j] = Mod(c[i][j] + c[i - 1][j - k]);
}

int main() {
    cin >> n >> m >> b >> mod;
    for (int i = 0; i < n; ++i)
        cin >> a, ++cnt[a];
    precalc();
    dp[0][0][0] = dp[1][0][0] = 1;
    int t = 0;
    for (int i = 0; i < MAXN; ++i)
        if (cnt[i]) {
            for (int j = 0; j <= m; ++j)
                for (int k = 0; k <= b; ++k) {
                    int l = i;
                    for (int z = 1; j + z <= m && k + l <= b; ++z, l *= i) {
                        dp[t ^ 1][j + z][k + l] = Mod(dp[t ^ 1][j + z][k + l] + (int)(((long long)c[cnt[i]][z] * (long long)dp[t][j][k]) % mod));
                    }
                }
            t ^= 1;
        }
    int sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = Mod(sum + dp[t][m][i]);
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b, mod;
int a, cnt[MAXN];
int dp[MAXN][MAXN], dp2[MAXN][MAXN];
int c[MAXN][MAXN];

void precalc() {
    for (int i = 0; i <= n; ++i)
        c[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = 0; k <= m; ++k)
                c[i][j] = (c[i][j] + c[i - 1][j - k]) % mod;
}

int main() {
    scanf("%d %d %d %d", &n, &m, &b, &mod);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a), ++cnt[a];
    precalc();
    dp[0][0] = dp2[0][0] = 1;
    for (int i = 0; i < MAXN; ++i)
        if (cnt[i]) {
            for (int j = 0; j < m; ++j)
                for (int k = 0; k <= b; ++k) {
                    for (int z = 1; j + z <= m && k + i * z <= b; ++z) {
                        dp2[j + z][k + i * z] = (dp2[j + z][k + i * z] + (c[cnt[i]][z] * dp[j][k]) % mod) % mod;
                    }
                }
            for (int i = 0; i <= m; ++i)
                for (int j = 0; j <= b; ++j)
                    dp[i][j] = dp2[i][j];
        }
    int sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = (sum + dp[m][i]) % mod;
    printf("%d\n", sum);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b;
long long mod;
int a;
int cnt[MAXN];
int dp[2][MAXN][MAXN];
int c[MAXN][MAXN];

inline int Mod(int x) {
    return x >= mod ? x - (int)mod : x;
}

void precalc() {
    for (int i = 0; i <= n; ++i)
        c[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = 0; k <= j; ++k)
                c[i][j] = Mod(c[i][j] + c[i - 1][j - k]);
}

int main() {
    cin >> n >> m >> b >> mod;
    for (int i = 0; i < n; ++i)
        scanf("%d", &a), ++cnt[a];
    precalc();
    dp[0][0][0] = dp[1][0][0] = 1;
    int t = 0;
    for (int i = 0; i < MAXN; ++i)
        if (cnt[i]) {
            for (int j = 0; j <= m; ++j)
                for (int k = 0; k <= b; ++k) {
                    int l = 1;
                    for (int z = 1; j + z <= m && k + l + i <= b; ++z, l += i) {
                        dp[t ^ 1][j + z][k + l] = Mod(dp[t ^ 1][j + z][k + l] + (int)(((long long)c[cnt[i]][z] * (long long)dp[t][j][k]) % mod));
                    }
                }
            t ^= 1;
        }
    int sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = Mod(sum + dp[t][m][i]);
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b, mod;
int a, cnt[MAXN];
int dp[MAXN][MAXN], dp2[MAXN][MAXN];
int c[MAXN][MAXN];

void precalc() {
    for (int i = 0; i <= n; ++i)
        c[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = 0; k <= m; ++k)
                c[i][j] = (c[i][j] + c[i - 1][j - k]) % mod;
}

int main() {
    scanf("%d %d %d %d", &n, &m, &b, &mod);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a), ++cnt[a];
    precalc();
    dp[0][0] = dp2[0][0] = 1;
    for (int i = 0; i < MAXN; ++i)
        if (cnt[i]) {
            for (int j = 0; j < m; ++j)
                for (int k = 0; k <= b; ++k) {
                    for (int z = 1; j + z <= m && k + i * z <= b; ++z) {
                        dp2[j + z][k + i * z] = (dp2[j + z][k + i * z] + (c[cnt[i]][z] * dp[j][k]) % mod) % mod;
                    }
                }
            for (int i = 0; i <= m; ++i)
                for (int j = 0; j <= b; ++j)
                    dp[i][j] = dp2[i][j];
        }
    int sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = (sum + dp[m][i]) % mod;
    printf("%d\n", sum);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b;
long long mod;
int a;
int cnt[MAXN];
int dp[2][MAXN][MAXN];
int c[MAXN][MAXN];

inline int Mod(int x) {
    return x >= mod ? x - (int)mod : x;
}

void precalc() {
    for (int i = 0; i <= n; ++i)
        c[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = 0; k <= j; ++k)
                c[i][j] = Mod(c[i][j] + c[i - 1][j - k]);
}

int main() {
    cin >> n >> m >> b >> mod;
    for (int i = 0; i < n; ++i)
        scanf("%d", &a), ++cnt[a];
    precalc();
    dp[0][0][0] = dp[1][0][0] = 1;
    int t = 0;
    for (int i = 0; i < MAXN; ++i)
        if (cnt[i]) {
            for (int j = 0; j <= m; ++j)
                for (int k = 0; k <= b; ++k) {
                    int l = i;
                    for (int z = 1; j + z <= m && k + l <= b; ++z, l += i) {
                        dp[t ^ 1][j + z][k + l] = Mod(dp[t ^ 1][j + z][k + l] + (int)(((long long)c[cnt[i]][z] * (long long)dp[t][j][k]) % mod));
                    }
                }
            t ^= 1;
        }
    int sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = Mod(sum + dp[t][m][i]);
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b;
long long mod;
int a;
int cnt[MAXN];
int dp[MAXN][MAXN], dp2[MAXN][MAXN];
int c[MAXN][MAXN];

inline int Mod(int x) {
    return x >= mod ? x - (int)mod : x;
}

void precalc() {
    for (int i = 0; i <= n; ++i)
        c[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = 0; k <= j; ++k)
                c[i][j] = Mod(c[i][j] + c[i - 1][j - k]);
}

int main() {
    cin >> n >> m >> b >> mod;
    for (int i = 0; i < n; ++i)
        cin >> a, ++cnt[a];
    precalc();
    dp[0][0] = dp2[0][0] = 1;
    for (int i = 0; i < MAXN; ++i)
        if (cnt[i]) {
            for (int j = 0; j <= m; ++j)
                for (int k = 0; k <= b; ++k) {
                    int p = i;
                    for (int z = 1; j + z <= m && k + p <= b; ++z, p += i) {
                        dp2[j + z][k + p] = Mod(dp2[j + z][k + p] + (int)(((long long)c[cnt[i]][z] * (long long)dp[j][k]) % mod));
                    }
                }
            for (int i = 0; i <= m; ++i)
                for (int j = 0; j <= b; ++j)
                    dp[i][j] = dp2[i][j];
        }
    int sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = Mod(sum + dp[m][i]);
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b;
long long mod;
int a[MAXN];
int dp[MAXN][MAXN];

inline int Mod(int x) {
    return x >= mod ? x - (int)mod : x;
}

int main() {
    cin >> n >> m >> b >> mod;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            for (int k = b; k >= 0; --k)
                if (k + a[i] <= b)
                    dp[j + 1][k + a[i]] = Mod(dp[j + 1][k + a[i]] + dp[j][k]);
    int sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = Mod(sum + dp[m][i]);
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

const int MAXN = 510;

int n, m, b;
long long mod;
int a;
long long cnt[MAXN];
long long dp[MAXN][MAXN], dp2[MAXN][MAXN];
long long c[MAXN][MAXN];

void precalc() {
    for (int i = 0; i <= n; ++i)
        c[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = 0; k <= j; ++k)
                c[i][j] = (c[i][j] + c[i - 1][j - k]) % mod;
}

int main() {
    cin >> n >> m >> b >> mod;
    for (int i = 0; i < n; ++i)
        cin >> a, ++cnt[a];
    precalc();
    dp[0][0] = dp2[0][0] = 1;
    for (int i = 0; i < MAXN; ++i)
        if (cnt[i]) {
            for (int j = 0; j < m; ++j)
                for (int k = 0; k <= b; ++k) {
                    for (int z = 1; j + z <= m && k + i * z <= b; ++z) {
                        dp2[j + z][k + i * z] = (dp2[j + z][k + i * z] + (c[cnt[i]][z] * dp[j][k]) % mod) % mod;
                    }
                }
            for (int i = 0; i <= m; ++i)
                for (int j = 0; j <= b; ++j)
                    dp[i][j] = dp2[i][j];
        }
    long long sum = 0;
    for (int i = 0; i <= b; ++i)
        sum = (sum + dp[m][i]) % mod;
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

long long n, m, b, mod;
long long ans = 0;
vector <int> a;
//vector <vector <vector <int> > > d;

int main()
{
    cin >> n >> m >> b >> mod;
    a.resize(n + 1);
    //d.resize(n + 1, vector <vector <int> > (m + 1, vector <int> (b + 1, 0)));

    long long d[2][m + 1][b + 1];
    for (int i = 0; i <= 1; i++)
        for (int y = 0; y <= m; y++)
            for (int k = 0; k <= b; k++)
                d[i][y][k] = 0;

    for (int i = 1; i <= n; i++)
        cin >> a[i];

    for (int i = 1; i <= 1; i++)
    {
        if (a[i] <= b)
            d[i][1][a[i]]++;
        d[i][0][0] = 1;
    }

    for (int i = 0; i <= b; i++)
        d[0][0][i] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int y = 1; y <= m; y++)
        {
            for (int k = 0; k <= b; k++)
            {
                if (k - a[i] >= 0)
                    d[i % 2][y][k] = d[(i - 1) % 2][y][k] + d[i % 2][y - 1][k - a[i]];
                else
                    d[i % 2][y][k] = d[(i - 1) % 2][y][k];
                d[i % 2][y][k] %= mod;
            }
        }
    }

    for (int i = 0; i <= b; i++)
    {
        ans += d[n % 2][m][i];
        ans %= mod;
    }
    cout << ans;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int n, m, b, mod;
long long ans = 0;
vector <int> a;
//vector <vector <vector <int> > > d;

int main()
{
    cin >> n >> m >> b >> mod;
    a.resize(n + 1);
    //d.resize(n + 1, vector <vector <int> > (m + 1, vector <int> (b + 1, 0)));

    long long d[n + 1][m + 1][b + 1];
    for (int i = 0; i <= n; i++)
        for (int y = 0; y <= m; y++)
            for (int k = 0; k <= b; k++)
                d[i][y][k] = 0;

    for (int i = 1; i <= n; i++)
        cin >> a[i];

    for (int i = 1; i <= n; i++)
    {
        if (a[i] <= b)
            d[i][1][a[i]]++;
        d[i][0][0] = 1;
    }

    for (int i = 0; i <= b; i++)
        d[0][0][i] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int y = 1; y <= m; y++)
        {
            for (int k = 0; k <= b; k++)
            {
                if (k - a[i] >= 0)
                    d[i][y][k] = d[i - 1][y][k] + d[i][y - 1][k - a[i]];
                else
                    d[i][y][k] = d[i - 1][y][k];
                d[i][y][k] %= mod;
            }
        }
    }

    for (int i = 0; i <= b; i++)
    {
        ans += d[n][m][i];
        ans %= mod;
    }
    cout << ans;
    return 0;
}