/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
const int MOD=998244353;
LL quick(LL A,LL B){
	if(B==0) return 1;
	LL  tmp=quick(A,B>>1);
	tmp*=tmp;
	tmp%=MOD;
	if(B&1)
		tmp*=A,tmp%=MOD;
 	return tmp;
}
void add(int & A,int B){
	A+=B;
	if(A>=MOD) A-=MOD;
}
int inv(int A){return quick(A,MOD-2);}
int x[200000+20];
int n,k;
const int MAXN=200000;
struct BIT{
	void add(int & A,int B){
		A+=B;
		if(A>=MOD) A-=MOD;
	}
	int bit[MAXN+10]={0};
	int sum(int i){
		int s=0;
		while(i>0){
			add(s,bit[i]);
			i-=i&(-i);
		}
		return s;
	}
	void modi(int i,int x=1){
		while(i<=n){
			add(bit[i],x);
			i+=i&(-i);	
		}
	}
}sum,cnt;
int main(){
	fastio;
	int rest=0;
	cin>>n>>k;
	rb(i,1,n) R(x[i]);
	int p=1ll*(k-1)*inv(k)%MOD;
	rl(i,n,1){
		int fi=max(0,i-k);
		int tmp;
		tmp=sum.sum(n)-sum.sum(x[i]);
		if(tmp<0) tmp+=MOD;
		tmp=1ll*tmp*inv(quick(p,fi))%MOD;
		add(rest,tmp);
		
		
		
		tmp=sum.sum(x[i]-1);
		int cn=cnt.sum(x[i]-1);
		tmp=1ll*tmp*inv(quick(p,fi))%MOD;
		cn-=tmp;
		if(cn<0) cn+=MOD;
		add(rest,cn);
		
		
		cnt.modi(x[i]);
		sum.modi(x[i],1ll*inv(2)*quick(p,fi)%MOD);
		
//		cout<<rest<<" "<<p<<endl;
	}
	cout<<rest<<endl;
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/
