#include <cstdio>
#include <iostream>
#define MAXN 1001
using namespace std;

int n,k,m,l;
int a[11],w[11];
int cc;
int f[MAXN];
bool eq;
int pr;


int main(){
	freopen("B.in","r",stdin); freopen("B.out","w",stdout);
	scanf("%d %d %d",&n,&m,&k);
	scanf("%d",&l);
	for (int i = 0; i < l; i++) scanf("%d",&a[i]);
	int q = 0; 
	bool ok;
	memset(f,0,sizeof(f));
	memset(w,0,sizeof(w));
	cc = 0;
	int g=  0;
	int mm = 0;
	eq = false;
	while (true){
		ok = true;
		for (int i = 0; i < l; i++) if (f[q+a[i]-1]) ok = false;
		if (ok){
			g++;
			for (int i = 0; i < l; i++) f[q+a[i]-1] = 1; 
			w[cc]=q+k;
			q = w[cc];
			mm= 0;
			for (int i = 0; i < m; i++) {
				if (w[i] > mm) mm= w[i];
				if (w[i] < q){
					q = w[i];
					cc = i;
				}
			}
		}else q++;

		if (q > 980 || g==n) break;
		if (!eq && k*2 <= mm)		
		for (int i = k; i < mm-1; i++){
  		    eq = true;
		    for  (int j = i; j < mm-1; j+=i){
			for (int t = 0; t < i, a[0]+j+t-1 < mm; t++)
			if (f[a[0]+t-1] != f[a[0]+j+t-1]){
			  eq= false; break;
			}
			if (!eq) break;
		    }
		    if (eq){
                        pr = (mm-a[0]+1)*(n/g-1);
			n = n % g;
			g= 0;
			break;
		    }
		}
		if (n==g) break;
		
	}
	if (g==n){
		int mm = 0;
		for (int i = 0; i < m; i++) mm = (w[i] > mm) ? w[i] : mm;
                mm+=pr;
		cout << mm << endl;
	}
	fclose(stdin); fclose(stdout);
	return 0;       
}