#include <bits/stdc++.h>
using namespace std;
const int N = 200005, M = 998244353;
int n, k, p[N], i, a[N], q[N];
long long tree[N], m[N], ans[N];
long long qpow(long long a, long long b) {
  long long s = a, ans = 1;
  while (b) {
    if (b & 1) ans = ans * s % M;
    s = s * s % M;
    b >>= 1;
  }
  return ans;
}
void modify(int x, int y) {
  while (x <= n) {
    tree[x] += y;
    x += -x & x;
  }
}
int Query(int x) {
  long long s = 0;
  while (x) {
    s += tree[x];
    x -= -x & x;
  }
  return s % M;
}
void dfs(int l, int r) {
  if (l == r) return;
  int mid = l + r >> 1, i;
  long long s = 0, tot = 0;
  for (i = l; i <= mid; ++i) {
    modify(p[i], m[i]);
    tot = (tot + m[i]) % M;
  }
  for (i = r; i > mid; --i) {
    ans[i] = (ans[i] + s) % M;
    s = (s + tot - Query(p[i])) % M;
  }
  for (i = l; i <= mid; ++i) modify(p[i], -m[i]);
  s = 0;
  for (i = mid + 1; i <= r; ++i) modify(p[i], 1);
  for (i = l; i <= mid; ++i) {
    s = (s + Query(p[i]) * m[i]) % M;
    ans[i] = (ans[i] + s) % M;
  }
  for (i = mid + 1; i <= r; ++i) modify(p[i], -1);
  dfs(l, mid);
  dfs(mid + 1, r);
}
int main() {
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
    q[p[i]] = i;
  }
  long long in = qpow(k, M - 2);
  long long iw = in * (k - 1) % M;
  long long iiw = qpow(iw, M - 2);
  for (i = 1; i <= n; ++i) m[i] = in * qpow(iw, n - max(i, k)) % M;
  dfs(1, n);
  long long s = ((n - k) * qpow(2, M - 2) % M * (k - 1) % M +
                 1ll * k * (k - 1) / 2 % M * qpow(2, M - 2)) %
                M;
  for (i = n - k; i >= 1; --i)
    s = (s + ans[i + k - 1] * qpow(iiw, n - i - k + 1)) % M;
  cout << (s % M + M) % M;
}
