#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int c;
    long long int x = 0;
    unsigned long long n, m, b[100000], i, j, a[50000];
    scanf("%llu %llu", &n, &m);
    for(i = 1; i <= m; i++)
        scanf("%llu ", &b[i]);


    scanf("%d", &c);


    for (i = 1; i <= n; i++)
        a[i] = i;

    for(i = 0; i < n - m; i++)
    {
        for(j = 1; j <= m; j++)
            a[i + b[j]] = a[i + j];
    }


    for (i = 1; i <= n - m; i++)
        x += pow(c, i) * a[i];


        printf("%lld", x % 998244353);

    return 0;
}