program lagano;
var
a:array[1..500000] of real;
b:array[1..100000] of longint;
i,j,t,l:integer;
m,n:longint;
c,q,x,power:real;
begin
read(n,m);
for t:=1 to m do
    begin
    read(b[t]);
    end;
read(c);
for t:=1 to n do
    begin
    a[t]:=t;
    end;
i:=0;
for i:=1 to n do
begin
for j:=1 TO M DO
begin
a[i+b[j]]:=a[i+j];
end;
end;
for i:=1 to n do
begin
power:=1;

    for l:=1 to i do
    begin
     power:=power*c;
     end;
    x:=x+power*a[i];
    end;
writeln(x:0:0);

{for t:=1 to n do
begin
    writeln(a[t]:0:0);
    end; }
end.