import java.util.Scanner;
import java.lang.Math;
public class Function {
	
	public static int n, m, x;
	
	public static int c;
	public static void main(String[] args) {
		
		System.out.println("Unesi N:");
		Scanner sn = new Scanner(System.in);
		
		System.out.println("Unesi M:");
		Scanner sm = new Scanner(System.in);
		
		
		
		n = sn.nextInt();
		m = sm.nextInt();
		
		
		long[] b = new long[m];
		long[] a = new long[n];
		
		
		for(int z = 0; z < m; z++) {
			
			System.out.println("Unesi Broj");
			Scanner scan = new Scanner(System.in);
			b[z] = scan.nextLong();
		}
		System.out.println("Unesi C:");
		Scanner sc = new Scanner(System.in);
		c = sc.nextInt();
		for(int z = 0; z < n; z++) {
			a[z] = z+1;
		}
		
		for(int i = 0; i <= (n-m); i++) {
			for(int j = 1; j <= (m); j++) {
				a[i+((int)b[j-1])-1] = a[i+j-1];
			}
		}
		
		for(int i = 0; i < n; i++) {
			x += ((Math.pow(c,i) * a[i]));
			//System.out.println(a[i]);
		}
		System.out.println(Math.abs(x % 998244353));
	}
}