#include <iostream>
#include <math.h>

#define ll long long
#define modul 998244353

using namespace std;

int main() {

    int n, m;

    cin >> n >> m;

    int b[m + 1], a[n + 1];

    for(int i = 1; i <= m; i++) {
        cin >> b[i];
        a[i] = i;
     }
    for(int i = m + 1; i <= n; i++)
        a[i] = i;

    int c;
    cin >> c;

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

    ll x = 0, ci = c;
    for(int i = 1; i <= n; i++) {
        x = (x + (ci * a[i]) % modul) % modul;
        ci = (ci * c) % modul;
    }

    cout << x << endl;
    return 0;
}