#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long n, m;
	int b[100];
	cin >> n >> m;
	for (int i = 1; i < m; i++)
	{
		cin >> b[i];
	}
	int a[100];
	for (int i = 1; i < n; i++)
	{
		a[i] = i;
	}
	for (int i = 1; i < n - m; i++)
		for (int j = 1; j <= m; j++)
		{
			a[i + b[j]] = a[i + j];
		}
	long long c;
	cin >> c;
	long long suma = 0;
	long long x;
	for (int i = 1; i < n - m; i++)
	{
		suma += pow(c, i)*a[i];
	}
	x = suma % 998244353;
	cout << x;
}