#include <iostream>

using namespace std;

long long stepen(int c, int i)
{
    long long c1 = 1;
    for(int j = 0; j < i; j++)
    {
        c1 *= c;
    }
    return c1;
}

int main()
{
    int m;
    int n;
    cin >> n;
    cin >> m;
    int *b = new int[m + 1];
    for(int l = 1; l <= m; l++)
    {
        cin >> b[l];
    }
    int c;
    cin >> c;
    int *a = new int[n + 1];
    for(int h = 1; h <= n; h++)
    {
        a[h] = h;
    }
    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 t = 1; t <= n; t++)
    {
        x += stepen(c, t) * a[t];
    }
    x = x % 998244353;
    cout << x;
    delete (a);
    delete (b);
    return 0;
}