#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define si short int
#define ll long long

//brute-force
int main(void)
{
    int n,m;
    cin>>n>>m;
    int b[m+1];
    int a[n+1]={0};
    //int start_s=clock();
    for(int i=0;i<=n-m;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(i==0)
                cin>>b[j];//b[j]=rand()%m;//cin>>b[j];//, cout<<b[j]<<endl;
            if(a[i+j]==0)
                a[i+j]=i+j+1;
            a[i+b[j]]=a[i+j];
        }
    }
    int c;
    cin>>c;
    ll poc=1;
    int x=0;
    for(int i=1;i<=n;i++)
        x+=c*poc*a[i], poc*=c;
    cout<<x%998244353<<endl;
    //int stop_s=clock();
    //cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC) << endl;
    //system("PAUSE");
}
//O((n-m)*m+n)= 1.990.000.000.000+20.000.000