#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

using mint = modint998244353;
#define N 212345
int p[N];

int main(){
	int n, k; scanf("%d%d", &n, &k);
	REP(i, n) scanf("%d", p+i);
	mint k1k = mint(k-1) / k;
	mint ans = 0;
	REP(i, n){
		FOR(j, i+1, n){
			int h = max(j-(k-1), 0) - max(i-(k-1), 0);
			DEBUG("(%d, %d) => %d\n", i, j, h);
			mint q = k1k.pow(h) * 1/2;
			if(p[i] > p[j]) q = 1-q;
			ans += q;
		}
	}
	printf("%d\n", ans.val());
}
