#include <iostream>

using namespace  std;

int n, m;
int c;
int main()
{
	cin >> n >> m;
	int *b = new int[m + 1];
	//int b[] = { 0,6,4,3,3,2,1 };
	for (int i = 1; i <= m; i++)
		cin >> b[i];
	cin >> c;
	int *a = new int[n+1];
	for (int i = 0; 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];
	}

	int x = 0;
	for (int i = 1; i <= n; i++)
		x += (int(pow(c, i)) * a[i]);
	x = x % 998244353;
	cout << x;
}