#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define x first
#define y second
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x,T y){x<y?x=y:T();}
template <typename T> void chkmin(T &x,T y){x>y?x=y:T();}
template <typename T> void readint(T &x)
{
	x=0;int f=1;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+c-'0';
	x*=f;
}
const int MOD=998244353;
inline int dmy(int x){return x>=MOD?x-MOD:x;}
inline void inc(int &x,int y){x=dmy(x+y);}
int qmi(int x,int y)
{
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%MOD)
		if(y&1)ans=1ll*ans*x%MOD;
	return ans;
}
const int MAXN=200005;

int n,k,a[MAXN],pw[MAXN],ipw[MAXN];
int c[MAXN];
void add(int x,int d){for(;x<=n;x+=(x&-x))inc(c[x],d);}
int query(int x){int s=0;for(;x;x-=(x&-x))inc(s,c[x]);return s;}

int main()
{
	#ifdef LOCAL
	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n),readint(k);
	for(int i=1;i<=n;++i)readint(a[i]);
	pw[0]=ipw[0]=1,pw[1]=dmy(1+MOD-qmi(k,MOD-2)),ipw[1]=qmi(pw[1],MOD-2);
	for(int i=2;i<=n;++i)pw[i]=1ll*pw[i-1]*pw[1]%MOD,ipw[i]=1ll*ipw[i-1]*ipw[1]%MOD;
	int ans=0,cnt=0;
	for(int i=1;i<=n;++i)
		inc(cnt,query(n)-query(a[i])),
		add(a[i],1);
	memset(c,0,sizeof(c));
	for(int i=1;i<=n;++i)
	{
		int u=max(i,k);
		int sn=query(n),si=query(a[i]);
		inc(ans,1ll*dmy(dmy(si<<1)-sn+MOD)*pw[u]%MOD);
		add(a[i],ipw[u]);
	}
	ans=(cnt+1ll*ans*qmi(2,MOD-2))%MOD;
	printf("%d\n",ans);
	return 0;
}