#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,p[200005],pw[200005],tr[2][200005],ans=0,alr,ty=0;
const int mod=998244353;
int mypow(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}
int lowbit(int p){return p&-p;}
int M(int x){return x>=mod?x-mod:x;}
void modify(int p,int v)
{
	while(p<=n)
	{
		tr[ty][p]=M(tr[ty][p]+v);
		p+=lowbit(p);
	}
}
int ask(int p)
{
	//printf("%d %d %d\n",p,ty,tr[0][2]);
	int ans=0;
	while(p)
	{
		ans=M(ans+tr[ty][p]);
		//printf("!%d %d %d\n",ans,p,tr[0][p]);
		p-=lowbit(p);
	}
	return ans;
}
int main()
{
	ty=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	pw[0]=1;
	pw[1]=1ll*(k)*mypow(k-1,mod-2)%mod;
	for(int i=2;i<=n;i++)pw[i]=1ll*pw[i-1]*pw[1]%mod;
	ans=1ll*k*(k-1)/2ll%mod*mypow(2,mod-2)%mod;
	alr=1ll*(k-1)*mypow(k,mod-2)%mod*mypow(2,mod-2)%mod;
	//printf("%d\n",ans);
	for(int i=1;i<=k;i++)modify(p[i],1),ty=1,modify(p[i],1),ty=0;
	for(int i=k+1;i<=n;i++)
	{
		ans=(1ll*ans+1ll*ask(p[i])*alr%mod)%mod;
		//printf("%d %d %d %d %d %d\n",ask(p[i]),alr,ans,mypow(4,mod-2),ask(n),ask(p[i]));
		ans=(1ll*ans-1ll*(ask(n)-ask(p[i])+mod)*alr%mod+mod)%mod;
		//printf("@%d\n",ans);
		ty=1;
		ans=(1ll*ans+ask(n)-ask(p[i]))%mod;
		modify(p[i],1);
		//printf("@%d %d %d %d\n",ans,ask(p[i]),ask(n));
		ty=0;
		modify(p[i],pw[i-k]);
		alr=1ll*alr*(k-1)%mod*mypow(k,mod-2)%mod;
	}
	printf("%d\n",ans);
}