#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}


const ll MOD = 998244353;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}


struct Fenwick {
	vector<ll> fenv;

	Fenwick() : fenv() {}
	Fenwick(int n) : fenv(vector<ll>(n, 0)) {}

	void fadd(int p, ll x) {
		for(; p < (int)fenv.size(); p |= p + 1)
			fenv[p] = add(fenv[p], x);
	}
	int get(int r) {
		int res = 0;
		for(; r >= 0; r = (r & (r + 1)) - 1)
			res = add(res, fenv[r]);
		return res;
	}
	int getSum(int l, int r) {
		if (l >= r) return 0;
		return sub(get(r - 1), get(l - 1));
	}
};

const int N = 200200;
int n, k;
ll pw[N], rpw[N];
pii ord[N];

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);
	pw[0] = 1;
	pw[1] = sub(1, rev(k));
	for (int i = 2; i < N; i++)
		pw[i] = mult(pw[i - 1], pw[1]);
	rpw[1] = rev(pw[1]);
	for (int i = 2; i < N; i++)
		rpw[i] = mult(rpw[i - 1], rpw[1]);

	Fenwick F1 = Fenwick(n), F2 = Fenwick(n), F3 = Fenwick(n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		ord[i] = mp(x, i);
	}
	sort(ord, ord + n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int x = ord[i].second;
		ll sumL = F1.getSum(0, x), sumR = F1.getSum(x + 1, n);
		ll sumRevL = F2.getSum(0, x), sumRevR = F2.getSum(x + 1, n);
		ll cntL = F3.getSum(0, x), cntR = F3.getSum(x + 1, n);
		ans = add(ans, mult(rev(2), mult(sumRevL, pw[max(k - 1, x)])));
		ans = add(ans, cntR);
		ans = sub(ans, mult(rev(2), mult(sumR, rpw[max(k - 1, x)])));
		F1.fadd(x, pw[max(k - 1, x)]);
		F2.fadd(x, rpw[max(k - 1, x)]);
		F3.fadd(x, 1);
	}
	printf("%lld\n", ans);

	return 0;
}
