program e2;
var n, m, c, i, j, k, x, y:longint;
    a:array[1..20000000] of integer;
    b:array[1..100000] of integer;

begin
        read(n,m);
        for i:=1 to m do read(b[i]);
        read(c);

        for i:=1 to n do a[i]:=i;

        for i:=0 to n-m do
        begin
                for j:=1 to m do a[i+b[j]]:=a[i+j];
        end;

        x:=0;
        for i:=1 to n do
        begin
                y:=1;
                for k:=1 to i do y:=y*c;
                x:=x+y*a[i];
        end;
        write(x);
end.