program takmicenje;
var n, m, c, cc, x, i, j, y:integer;
a, b:array [1..500000] of int64;
begin
x := 0;
read(n,m);
for i := 1 to m do read(b[i]);
read(c);
cc := c;
for i := 1 to n do a[i] := i;
for i := 0 to n-m do for j := 1 to m do
begin
y := b[j];
a[i + y] := a[i + j];
end;
for i := 1 to n do
begin
x := x + c*a[i];
c := c*cc;
end;
writeln(x);
end.