#include <bits/stdc++.h>
using namespace std;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;
long long int N, M, K, T, H, W, L, R;
class Add_Segment_Tree {
  vector<long long int> v;
  long long int ret;
  int num;
  long long int Update(int place) {
    if (place >= v.size() / 2) {
      return v[place];
    }
    v[place] = Update(place * 2) + Update(place * 2 + 1);
    return v[place];
  }

 public:
  Add_Segment_Tree(int n) {
    n++;
    num = 1;
    while (num < n * 2) num *= 2;
    v.resize(num, 0);
  }
  void Add(int place, long long int num, bool update) {
    place += v.size() / 2;
    v[place] += num;
    if (!update) return;
    place /= 2;
    while (place) {
      v[place] = v[place * 2] + v[place * 2 + 1];
      place /= 2;
    }
  }
  void TopDown() { Update(1); }
  long long int Sum(int a, int b) {
    ret = 0;
    b++;
    for (a += num / 2, b += num / 2; a < b; a >>= 1, b >>= 1) {
      if (a & 1) ret += v[a++];
      if (b & 1) ret += v[--b];
    }
    return ret;
  }
};
long long int power(long long int x, long long int n, long long int M) {
  long long int ret = 1;
  long long int by = x;
  while (n) {
    if (n & 1) {
      ret *= by;
      ret %= M;
    }
    by *= by;
    by %= M;
    n >>= 1;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  long long int ans = 0;
  vector<int> v(N);
  for (auto &i : v) cin >> i;
  Add_Segment_Tree asg(N);
  Add_Segment_Tree num(N);
  vector<long long int> by(N - K + 2, 1);
  by.back() = 1;
  for (int i = by.size() - 2; i >= 0; i--) {
    by[i] = by[i + 1] * (K - 1);
    by[i] %= MOD;
    by[i] *= power(K, MOD - 2, MOD);
    by[i] %= MOD;
  }
  ans += (K - 1) * K / 2 * power(2, MOD - 2, MOD);
  ans %= MOD;
  for (int i = 0; i < K; i++) {
    asg.Add(v[i], by[1], true);
    num.Add(v[i], 1, true);
  }
  for (int i = K; i < N; i++) {
    ans -= asg.Sum(v[i] + 1, N) * power(by[i - K + 2], MOD - 2, MOD) % MOD *
           power(2, MOD - 2, MOD) % MOD;
    ans += num.Sum(v[i] + 1, N);
    ans += asg.Sum(1, v[i] - 1) * power(by[i - K + 2], MOD - 2, MOD) % MOD *
           power(2, MOD - 2, MOD) % MOD;
    num.Add(v[i], 1, true);
    asg.Add(v[i], by[i - K + 2], true);
    ans += MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
