#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int add(int a, int b) {
  a += b;
  if (a >= MOD) {
    return a - MOD;
  }
  if (a < 0) {
    return a + MOD;
  }
  return a;
}
int mul(int a, int b) { return a * (long long)b % MOD; }
int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) {
      r = mul(r, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return r;
}
int dv(int a, int b) { return mul(a, pw(b, MOD - 2)); }
const int N = (int)2e5 + 7;
int n;
int k;
int a[N];
int enter[N];
int val;
int prob_swap(int i, int j) { return dv(pw(val, enter[j] - enter[i]), 2); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    enter[i] = max(0, i - k);
  }
  val = dv(k - 1, k);
  int invs = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] < a[j]) {
        invs = add(invs, prob_swap(i, j));
      } else {
        invs = add(invs, add(1, -prob_swap(i, j)));
      }
    }
  }
  cout << invs << "\n";
  return 0;
}
