#include <bits/stdc++.h>
using namespace std;
long long int fac[10000000 + 1], inv[10000000 + 1], finv[10000000 + 1];
long long int comb(long long int n, long long int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  return (((fac[n] * finv[n - k]) % 998244353) * finv[k]) % 998244353;
}
long long int perm(long long int n, long long int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  return (fac[n] * finv[n - k]) % 998244353;
}
void init() {
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for (int i = 2; i <= 10000000; i++) {
    fac[i] = (fac[i - 1] * i) % 998244353;
    inv[i] = ((-(998244353 / i) * inv[998244353 % i]) % 998244353 + 998244353) %
             998244353;
    finv[i] = (finv[i - 1] * inv[i]) % 998244353;
  }
}
long long int pp(long long int a, long long int b) {
  return (a * b) % 998244353;
}
long long int mpow(long long int a, long long int b, long long int p = -1) {
  long long int ret = 1, num = a;
  while (b > 0) {
    if (b & 1) ret = (ret * num) % p;
    num = (num * num) % p;
    b /= 2;
  }
  return ret;
}
struct LazySegmentTree {
 private:
  int n;
  vector<long long int> node, lazy;

 public:
  LazySegmentTree(vector<long long int> v) {
    int sz = (int)v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1);
    lazy.resize(2 * n - 1, 0);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = (node[i * 2 + 1] + node[i * 2 + 2]) % 998244353;
  }
  void eval(int k, int l, int r) {
    if (lazy[k] != 0) {
      node[k] = (node[k] * lazy[k]) % 998244353;
      if (r - l > 1) {
        lazy[2 * k + 1] = (lazy[2 * k + 1] + lazy[k]) % 998244353;
        lazy[2 * k + 2] = (lazy[2 * k + 2] + lazy[k]) % 998244353;
      }
      lazy[k] = 0;
    }
  }
  void ml(int a, int b, long long int x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = (lazy[k] + x) % 998244353;
      eval(k, l, r);
    } else {
      ml(a, b, x, 2 * k + 1, l, (l + r) / 2);
      ml(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = (node[2 * k + 1] + node[2 * k + 2]) % 998244353;
    }
  }
  void add(int a, int b, long long int x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      eval(k, l, r);
      if (k < n - 1) add(a, b, x, 2 * k + 1, l, (l + r) / 2);
      if (k < n - 1) add(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = (node[k] + x) % 998244353;
    } else {
      add(a, b, x, 2 * k + 1, l, (l + r) / 2);
      add(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = (node[2 * k + 1] + node[2 * k + 2]) % 998244353;
    }
  }
  long long int getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return node[k];
    long long int vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
    long long int vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
    return (vl + vr) % 998244353;
  }
};
struct BIT {
  long long int M = 1;
  vector<long long int> dat;
  BIT(long long int N) {
    if (N <= 1) N = 2;
    while (N > M) M *= 2;
    dat.resize(M * 2 - 1, 0);
  }
  void update(long long int x, long long int k) {
    for (int i = k + 1; i <= M; i += (i & (-i))) {
      dat[i] += x;
    }
  }
  long long int sum(long long int r) {
    long long int ret = 0;
    for (int k = r; k > 0; k -= (k & (-k))) ret += dat[k];
    return ret;
  }
  long long int query(long long int l, long long int r) {
    return sum(r) - sum(l);
  }
};
int main() {
  long long int n, k;
  std::cin >> n >> k;
  init();
  vector<long long int> p(n);
  for (long long int i = 0; i < n; i++) {
    scanf("%lld", &p[i]);
    p[i]--;
  }
  BIT bt(n);
  LazySegmentTree seg(vector<long long int>(n, 0));
  long long int ans = 0;
  for (int i = 0; i < k; i++) {
    long long int lef = seg.getsum(0, p[i]);
    long long int ri = seg.getsum(p[i], n);
    long long int num = bt.query(p[i], n);
    long long int psum =
        ((lef * inv[2]) % 998244353 + (ri * inv[2]) % 998244353 +
         (num - ri + 998244353) % 998244353) %
        998244353;
    ans = (ans + psum) % 998244353;
    seg.add(p[i], p[i] + 1, 1);
    bt.update(1, p[i]);
  }
  long long int x = ((k - 1) * inv[k]) % 998244353;
  for (int i = k; i < n; i++) {
    seg.ml(0, n, x);
    long long int lef = seg.getsum(0, p[i]);
    long long int ri = seg.getsum(p[i], n);
    long long int num = bt.query(p[i], n);
    long long int psum =
        ((lef * inv[2]) % 998244353 + (ri * inv[2]) % 998244353 +
         (num - ri + 998244353) % 998244353) %
        998244353;
    ans = (ans + psum) % 998244353;
    seg.add(p[i], p[i] + 1, 1);
    bt.update(1, p[i]);
  }
  std::cout << ans << '\n';
}
