#include using namespace std; #define itn int #define rep(i,n) for(long long i=0;i<(long long)n;i++) #define reps(i,n) for(long long i=1;i<=(long long)n;i++) #define loop(i,l,r) for(long long i=l;i<=(long long)r;i++) #define drep(i,n) for(long long i=(long long)n-1;i>=0;i--) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define yn(x) cout << (x? "Yes":"No") << endl; #define cou(x) cout << x << endl; #define emp emplace_back #pragma GCC target ("avx,avx2")//四則演算 #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops")//ループ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")//浮動小数点 const long long mod=998244353LL; const long long mods=1000000007LL; const double inf=numeric_limits::infinity(); const int kaz=1000000000; const long long yab=2500000000000000000LL; const long long aho =-yab; const long double eps=1.0e-14L; const long double pi=acosl(-1.0L); using ll=long long; using st=string; using P=pair; using tup=tuple; using vi=vector; using vin=vector; using vc=vector; using vb=vector; using vd=vector; using vs=vector; using vp=vector

; using sp=set

; using si=set; using vvi=vector>; using vvin=vector; using vvc=vector; using vvb=vector; using vvvi=vector; using vvvin=vector; const int dx[4]={0,1,0,-1}; const int dy[4]={1,0,-1,0}; const vector ex = {-1, -1, -1, 0, 0, 1, 1, 1}; const vector ey = {-1, 0, 1, -1, 1, -1, 0, 1}; templateistream&operator>>(istream&is,vector&v){for(T&in:v)is>>in;return is;} templateostream&operator<<(ostream&os,vectorv){rep(i,v.size())os< void co(bool x,T1 y,T2 z){ if(x)cout << y << endl; else cout << z << endl; } template bool chmax(T &a, T b){ if(a bool chmin(T &a, T b){ if(a>b){ a=b; return true; } return false; } template void print(vector &a){ for(int i=0;i0){ if(y&1)ret=ret*x%m; x=x*x%m; y>>=1; } return ret; } ll nopow(ll x,ll y){ ll ret=1; while(y>0){ if(y&1)ret*=x; x*=x; y>>=1; } return ret; } int main(){ ll n,k; cin >> n >> k; vi a(n); cin >> a; reverse(all(a)); ll t=accumulate(all(a),0LL); ll res=0; rep(i,n){ res=(res+a[i]*mypow(k,i-1,t))%mod; } cout << res << endl; }