#include <bits/stdc++.h>
using namespace std;

const int N = 200005;
const long long mod = 998244353ll, Inv2 = mod + 1 >> 1;

long long qpow(long long a, long long b) {
	long long res = 1ll;
	for (; b; b >>= 1, a = a * a % mod) {
		if (b & 1) res = res * a % mod;
	}
	return res;
}

int n, k, perm[N];
long long bit[N], ans = 0ll;
int lowbit(int x) {
	return x & -x;
}
struct fenwick {
	long long bit[N];
	void clear() {
		for (int i = 0; i <= n; i++) bit[i] = 0;
	}
	void add(int pos, long long x){
		for (; pos <= n; pos += lowbit(pos)) bit[pos] = (bit[pos] + x) % mod;
	}
	long long query(int pos) {
		long long res = 0;
		for (; pos; pos ^= lowbit(pos)) res = (res + bit[pos]) % mod;
		return res;
	}
} bit1, bit2;

long long inv1, inv2, pw1[N], pw2[N];
int pre[N];
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &perm[i]);

	// We calculate the contribution of (l, r) (1 <= l < r <= n)
	// Part 1 : l <= k
	// Initialize
	ans = (ans + 1ll * k * (k - 1) / 2 % mod * Inv2) % mod;
	inv1 = qpow(k, mod - 2) * (k - 1) % mod;
	inv2 = qpow(inv1, mod - 2);
	pw1[0] = 1ll, pw2[0] = 1ll;
	for (int i = 1; i <= n; i++) {
		pw1[i] = pw1[i - 1] * inv1 % mod;
		pw2[i] = pw2[i - 1] * inv2 % mod;
	}
	for (int i = 0; i <= n; i++) pre[i] = 0;
	for (int i = 1; i <= k; i++) pre[perm[i]] = 1;
	for (int i = 1; i <= n; i++) pre[i] += pre[i - 1];
	for (int i = k + 1; i <= n; i++) {
		// p_l < p_r
		ans = (ans + Inv2 * pw1[i - k] % mod * pre[perm[i]]) % mod;
		// p_l > p_r
		ans = (ans + (k - pre[perm[i]])) % mod;
		ans = (ans + mod - Inv2 * pw1[i - k] % mod * (k - pre[perm[i]]) % mod) % mod;
	}

	// Part 2: l > k
	bit1.clear(), bit2.clear();
	for (int i = k + 1; i <= n; i++) {
		// p_l < p_r
		ans = (ans + Inv2 * pw1[i] % mod * bit2.query(perm[i])) % mod;
		// p_l > p_r
		ans = (ans + bit1.query(n) - bit1.query(perm[i])) % mod;
		ans = (ans + mod - Inv2 * pw1[i] % mod * (bit2.query(n) + mod - bit2.query(perm[i])) % mod) % mod;
		bit1.add(perm[i], 1), bit2.add(perm[i], pw2[i]);
	}
	printf("%lld\n", ans);
	return 0;
}