#include <bits/stdc++.h>
using namespace std;
int N, K;
int A[202020];
signed long long mo = 998244353;
template <class V, int ME>
class BIT_mod {
 public:
  V bit[1 << ME];
  BIT_mod() { memset(bit, 0, sizeof(bit)); };
  V operator()(int e) {
    signed long long s = 0;
    e++;
    while (e) s += bit[e - 1], e -= e & -e;
    return s % mo;
  }
  void add(int e, V v) {
    e++;
    while (e <= 1 << ME) {
      bit[e - 1] += v;
      bit[e - 1] -= (bit[e - 1] >= mo) ? mo : 0;
      e += e & -e;
    }
  }
};
BIT_mod<signed long long, 20> bt, num;
signed long long modpow(signed long long a, signed long long n = mo - 2) {
  signed long long r = 1;
  a %= mo;
  while (n) r = r * ((n % 2) ? a : 1) % mo, a = a * a % mo, n >>= 1;
  return r;
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> K;
  for (i = 0; i < (N); i++) cin >> A[i];
  signed long long r2 = (mo + 1) / 2;
  signed long long ret = 0;
  for (i = 0; i < (K); i++) {
    bt.add(A[i], 1);
    num.add(A[i], 1);
  }
  ret = K * (K - 1) * r2 % mo * r2 % mo;
  signed long long p = (K - 1) * modpow(K) % mo;
  signed long long rp = 1;
  signed long long c = 1;
  for (i = K; i < N; i++) {
    c = c * p % mo;
    (ret += bt(A[i]) * (c * r2 % mo)) %= mo;
    (ret += (mo + bt(N) - bt(A[i])) * (mo - c * r2 % mo)) %= mo;
    (ret += (mo + num(N) - num(A[i]))) %= mo;
    bt.add(A[i], modpow(c));
    num.add(A[i], 1);
  }
  cout << ret << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
