#include <bits/stdc++.h>
long long power(long long a, long long b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b & 1ll) {
      x = (x * y) % 998244353;
    }
    y = (y * y) % 998244353;
    b >>= 1;
  }
  return x % 998244353;
}
long long modular_inverse(long long n) { return power(n, 998244353 - 2); }
long long ssize = 524288, vd = 0;
void sinit(long long stree[], long long lazy[]) {
  long long i, j;
  for (i = 0; i < 2 * ssize; i++) {
    stree[i] = 0;
    lazy[i] = 1;
  }
  return;
}
void eval(long long k, long long stree[], long long lazy[]) {
  if (lazy[k] != 1) {
    stree[k] *= lazy[k];
    stree[k] %= 998244353;
    if (k < (ssize - 1)) {
      lazy[2 * k + 1] *= lazy[k];
      lazy[2 * k + 1] %= 998244353;
      lazy[2 * k + 2] *= lazy[k];
      lazy[2 * k + 2] %= 998244353;
    }
    lazy[k] = 1;
  }
  return;
}
void upd(long long k, long long a, long long stree[], long long lazy[]) {
  long long i, m, w, l, r;
  long long mem[128];
  long long ld, rd, md;
  k += ssize - 1;
  mem[0] = k;
  w = 1;
  while (k > 0) {
    k = (k - 1) / 2;
    mem[w] = k;
    w++;
  }
  l = 0;
  r = ssize;
  eval(0, stree, lazy);
  for (i = w - 1; i > 0; i--) {
    eval((2 * mem[i]) + 1, stree, lazy);
    eval((2 * mem[i]) + 2, stree, lazy);
  }
  stree[mem[0]] = a;
  lazy[mem[0]] = 1;
  for (i = 1; i < w; i++) {
    k = mem[i];
    ld = stree[2 * k + 1];
    rd = stree[2 * k + 2];
    md = ld + rd;
    md %= 998244353;
    stree[k] = md;
  }
  return;
}
void multquery(long long a, long long b, long long t, long long k, long long l,
               long long r, long long stree[], long long lazy[]) {
  long long ld, rd, md;
  long long i, lp, rp;
  eval(k, stree, lazy);
  if (r <= a || b <= l) {
    return;
  }
  if (a <= l && r <= b) {
    lazy[k] *= t;
    lazy[k] %= 998244353;
    eval(k, stree, lazy);
    return;
  } else {
    eval(k * 2 + 1, stree, lazy);
    eval(k * 2 + 2, stree, lazy);
    multquery(a, b, t, k * 2 + 1, l, (l + r) / 2, stree, lazy);
    multquery(a, b, t, k * 2 + 2, (l + r) / 2, r, stree, lazy);
    stree[k] = (stree[k * 2 + 1] + stree[k * 2 + 2]) % 998244353;
    lazy[k] = 1;
    return;
  }
}
long long sumquery(long long a, long long b, long long k, long long l,
                   long long r, long long stree[], long long lazy[]) {
  long long ld, rd, md;
  long long i, lp, rp;
  eval(k, stree, lazy);
  if (r <= a || b <= l) {
    return vd;
  }
  if (a <= l && r <= b) {
    return stree[k];
  } else {
    ld = sumquery(a, b, k * 2 + 1, l, (l + r) / 2, stree, lazy);
    rd = sumquery(a, b, k * 2 + 2, (l + r) / 2, r, stree, lazy);
    lp = 0;
    rp = 0;
    md = ld + rd;
    md %= 998244353;
    return md;
  }
}
int main() {
  long long ms[1048576], ml[1048576];
  long long ks[1048576], kl[1048576];
  long long n, k, a[524288];
  scanf("%lld%lld", &n, &k);
  long long iv = k - 1;
  iv *= modular_inverse(k);
  iv %= 998244353;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  sinit(ms, ml);
  sinit(ks, kl);
  for (int i = 1; i <= k; i++) {
    upd(a[i], 1, ms, ml);
    upd(a[i], a[i], ks, kl);
  }
  long long res = 0;
  long long niv = modular_inverse(k);
  for (int i = k + 1; i <= n; i++) {
    long long v;
    v = sumquery((i - k), ssize, 0, 0, ssize, ks, kl);
    v += 998244353;
    v -=
        (((i - k) * sumquery((i - k), ssize, 0, 0, ssize, ms, ml)) % 998244353);
    v %= 998244353;
    v *= niv;
    v %= 998244353;
    res += v;
    res %= 998244353;
    multquery(0, ssize, iv, 0, 0, ssize, ms, ml);
    multquery(0, ssize, iv, 0, 0, ssize, ks, kl);
    upd(a[i], 1, ms, ml);
    upd(a[i], a[i], ks, kl);
  }
  long long vv = k;
  for (int i = n - k + 1; i <= n; i++) {
    long long nniv = modular_inverse(vv);
    long long v;
    v = sumquery(i, ssize, 0, 0, ssize, ks, kl);
    v += 998244353;
    v -= ((i * sumquery(i, ssize, 0, 0, ssize, ms, ml)) % 998244353);
    v %= 998244353;
    v *= nniv;
    v %= 998244353;
    res += v;
    res %= 998244353;
    nniv = vv - 1;
    nniv *= modular_inverse(vv);
    nniv %= 998244353;
    multquery(0, ssize, nniv, 0, 0, ssize, ms, ml);
    multquery(0, ssize, nniv, 0, 0, ssize, ks, kl);
    vv--;
  }
  printf("%lld\n", res % 998244353);
  return 0;
}
