program zad3;
uses math;
var a,b:array[1..20000000] of longint;
var n,m,i,j,c,sigma:longint;
begin
  sigma:=0;
  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
    for j:=1 to m do
        begin
          A[i + B[j]] := A[i + j];
        end;
  for i:=1 to n do
        sigma:=sigma+(c ** i)*a[i];
  write(sigma mod 998244353);
end.