#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int A[1000],B[1000],i,N,M;
    int C;
    unsigned long X;
    cin>>N;cin>>M;
    for(i=1;i<=M;i++){
     cin>>B[i];
    }
    for(i=1;i<=N;i++){
     A[i]=i;
    }
   for(i=0;i<N-M;i++){
     for(int j=1;j<=M;j++){
     A[i+B[j]]=A[i+j];
    }
    }
    cin>>C;
    for(i=1;i<=N;i++){
     X=(unsigned long)(pow(C,i)*A[i])+2;
    }
    cout<<X;
    return 0;
}