#include <iostream>
#include <math.h>
#define MAX_B 1000002
#define MAX_A 20000002


using namespace std;

long long stepen(long long a, long long b) {
	if (b == 0)
		return 1;
	long long res = stepen(a, b / 2);
	if (b % 2)
		return res * res * a;
	else
		return res * res;
}

int main() {
	int M,B[MAX_B],A[MAX_A];
	long long X=0,C,N,i,j;
	cin >> N >> M;
	for (i = 1; i <= M; i++) cin >> B[i];
	cin >> C;
	for (i = 1; i <= N; i++) A[i] = i;
	i = 0;
	for(i=0;i<=N-M;i++)
	for (j = 1; j <= M; j++) {
		A[i + B[j]] = A[i + j];
	}
	for (i = 1; i <= N; i++) {
		X = X + (stepen(C, i)*A[i]);
	}
	cout << X;
}