#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=200005,P=998244353,inv2=(P+1)/2;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
int n,K,a[N],id[N];
int fpow(int k1,int k2){
	int k3=1;
	for(;k2;k2>>=1,k1=1LL*k1*k1%P)if(k2&1)k3=1LL*k3*k1%P;
	return k3;
}
struct BIT{
	int t[N];
	void upd(int k1,int k2){
		for(int i=k1;i<=n;i+=i&-i)(t[i]+=k2)%=P;
	}
	int qry(int k1){
		int k2=0;
		for(int i=k1;i;i&=i-1)(k2+=t[i])%=P;
		return k2;
	}
	int qry(int l,int r){
		if(l>r)return 0;
		return (qry(r)+P-(l<=1?0:qry(l-1)))%P;
	}
}T1,T2,T3;
bool cmp(int k1,int k2){return a[k1]>a[k2];}
int main(){
	rd(n),rd(K);
	rep(i,1,n)rd(a[i]),id[i]=i;
	sort(id+1,id+1+n,cmp);
	int ans=0;
	int p=1LL*(K-1)*fpow(K,P-2)%P;
	int ip=fpow(p,P-2);
	rep(_,1,n){
		int i=id[_];
		if(i<=K){
			int sumr=1LL*inv2*T1.qry(K+1,n)%P*fpow(ip,K)%P;
			(ans+=sumr)%=P;
			int suml=1LL*inv2*T3.qry(1,K)%P;
			(ans+=suml)%=P;
		}else{
			int sumr=1LL*inv2*T1.qry(i+1,n)%P*fpow(ip,i)%P;
			(ans+=sumr)%=P;
			int summ=(P+T3.qry(K+1,i-1)-1LL*inv2*T2.qry(K+1,i-1)%P*fpow(ip,n-i+1)%P)%P;
			(ans+=summ)%=P;
			int suml=(P+T3.qry(1,K)-1LL*inv2*T3.qry(1,K)%P*fpow(p,i-K)%P)%P;
			(ans+=suml)%=P;
		}
		T1.upd(i,fpow(p,i));
		T2.upd(i,fpow(p,n-i+1));
		T3.upd(i,1);
	}
	pt(ans,'\n');
	return 0;
}