#include <bits/stdc++.h>

using namespace std;

long long powe(long long s,int i)
{
    return (long long int)(pow(s,i));
}

int main()
{
    long long int n,m;
    cin >> n >> m;
    vector<long> b(m+1);
    for(int i=1;i<=m;++i)
        cin >> b[i];
    long c;
    cin >> c;
    vector<long> a(n+1);
    for(int i=1;i<=n;++i)
        a[i]=i;
    for(int i=0;i<=n-m;++i)
    {
        for(int j=1;j<=m;++j)
            a[i+b[j]]=a[i+j];
    }
    long long x=0;
    for(int i=1;i<=n;++i)
      {
          x=(x+(powe(c,i)*a[i]))%998244353;
      }
    cout << x << endl;
    return 0;
}