#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

namespace io {
#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
  const int SIZE = (1 << 21) + 1;
  char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1;
  inline char getc () {return (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++);}
  inline void flush () {fwrite (obuf, 1, oS - obuf, stdout); oS = obuf;}
  inline void putc (char x) {*oS ++ = x; if (oS == oT) flush ();}
  template<class T>
  inline void read(T &x) {
    char ch; int f = 1;
    x = 0;
    while(isspace(ch = getc()));
    if(ch == '-') ch = getc(), f = -1;
    do x = x * 10 + ch - '0'; while(isdigit(ch = getc()));
    x *= f;
  }
  template<class T, class ...Args>
  inline void read(T &x, Args&... args) {read(x); read(args...);}
  template<class T>
  inline void write(T x) {
    static char stk[128];
    int top = 0;
    if(x == 0) {putc('0'); return;}
    if(x < 0) putc('-'), x = -x;
    while(x) stk[top++] = x % 10, x /= 10;
    while(top) putc(stk[--top] + '0');
  }
  template<class T, class ...Args>
  inline void write(T x, Args... args) {write(x); putc(' '); write(args...);}
  inline void space() {putc(' ');}
  inline void endl() {putc('\n');}
  struct _flush {~_flush() {flush();}} __flush;
};
using io::read; using io::write; using io::flush; using io::space; using io::endl; using io::getc; using io::putc;

const int M = 998244353;
inline int add(int x, int y) {return x+y>=M ? x+y-M : x+y;}
template<class ...Args> inline int add(int x, int y, Args... args) {return add(add(x, y), args...);}
inline int sub(int x, int y) {return x-y<0 ? x-y+M : x-y;}
inline int mul(int x, int y) {return 1LL * x * y % M;}
template<class ...Args> inline int mul(int x, int y, Args... args) {return mul(mul(x, y), args...);}
inline void inc(int &x, int y=1) {x += y; if(x >= M) x -= M;}
inline void dec(int &x, int y=1) {x -= y; if(x < 0) x += M;}
inline int power(int x, int y){
  int res = 1;
  for(; y; y>>=1, x = mul(x, x)) if(y & 1) res = mul(res, x);
  return res;
}
inline int inv(int x){return power(x, M - 2);}

const int N = 200005;
int tr[N];
int cnt[N];
int n, tot = 0, totc = 0;
void modify(int p, int v) {
  inc(tot, v); ++totc;
  for (; p <= n; p += p & -p) inc(tr[p], v), ++cnt[p];
}
pair<int, int> query(int p) {
  ll s = 0;
  int c = 0;
  for (; p; p ^= p & -p) s += tr[p], c += cnt[p];
  return make_pair(int(s % M), c);
}

int p[N], Pk[N], iPk[N];

int main() {
  int k;
  read(n, k);
  for (int i = 1; i <= n; ++i)
    read(p[i]);
  int s1 = mul(k, k - 1, inv(4)), s2 = 0;
  Pk[0] = 1; iPk[0] = 1;
  Pk[1] = mul(k - 1, inv(k)); iPk[1] = inv(Pk[1]);
  for (int i = 2; i <= n; ++i) Pk[i] = mul(Pk[i - 1], Pk[1]);
  for (int i = 2; i <= n; ++i) iPk[i] = mul(iPk[i - 1], iPk[1]);
  for (int i = 1; i <= k; ++i)
    modify(p[i], iPk[k]);
  for (int i = k + 1; i <= n; ++i) {
    pair<int, int> q = query(p[i] - 1);
    int lt = q.first, gt = sub(tot, lt);
    int gtc = totc - q.second;
    inc(s2, mul(lt, Pk[i]));
    inc(s2, sub(add(gtc, gtc), mul(gt, Pk[i])));
    modify(p[i], iPk[i]);
  }
  write(add(s1, mul(s2, (M + 1) / 2))), endl();
  return 0;
}
### Prompt

Generate a Cpp solution to the following problem:

Given are a permutation p_1, p_2, \dots, p_N of (1, 2, ..., N) and an integer K. Maroon performs the following operation for i = 1, 2, \dots, N - K + 1 in this order:

* Shuffle p_i, p_{i + 1}, \dots, p_{i + K - 1} uniformly randomly.



Find the expected value of the inversion number of the sequence after all the operations are performed, and print it modulo 998244353.

More specifically, from the constraints of this problem, it can be proved that the expected value is always a rational number, which can be represented as an irreducible fraction \frac{P}{Q}, and that the integer R that satisfies R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353 is uniquely determined. Print this R.

Here, the inversion number of a sequence a_1, a_2, \dots, a_N is defined to be the number of ordered pairs (i, j) that satisfy i < j, a_i > a_j.

Constraints

* 2 \leq N \leq 200,000
* 2 \leq K \leq N
* (p_1, p_2, \dots, p_N) is a permutation of (1, 2, \dots, N).
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N K
p_1 p_2 ... p_N


Output

Print the expected value modulo 998244353.

Examples

Input

3 2
1 2 3


Output

1


Input

10 3
1 8 4 9 2 3 7 10 5 6


Output

164091855

### Response

```cpp
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

namespace io {
#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
  const int SIZE = (1 << 21) + 1;
  char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1;
  inline char getc () {return (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++);}
  inline void flush () {fwrite (obuf, 1, oS - obuf, stdout); oS = obuf;}
  inline void putc (char x) {*oS ++ = x; if (oS == oT) flush ();}
  template<class T>
  inline void read(T &x) {
    char ch; int f = 1;
    x = 0;
    while(isspace(ch = getc()));
    if(ch == '-') ch = getc(), f = -1;
    do x = x * 10 + ch - '0'; while(isdigit(ch = getc()));
    x *= f;
  }
  template<class T, class ...Args>
  inline void read(T &x, Args&... args) {read(x); read(args...);}
  template<class T>
  inline void write(T x) {
    static char stk[128];
    int top = 0;
    if(x == 0) {putc('0'); return;}
    if(x < 0) putc('-'), x = -x;
    while(x) stk[top++] = x % 10, x /= 10;
    while(top) putc(stk[--top] + '0');
  }
  template<class T, class ...Args>
  inline void write(T x, Args... args) {write(x); putc(' '); write(args...);}
  inline void space() {putc(' ');}
  inline void endl() {putc('\n');}
  struct _flush {~_flush() {flush();}} __flush;
};
using io::read; using io::write; using io::flush; using io::space; using io::endl; using io::getc; using io::putc;

const int M = 998244353;
inline int add(int x, int y) {return x+y>=M ? x+y-M : x+y;}
template<class ...Args> inline int add(int x, int y, Args... args) {return add(add(x, y), args...);}
inline int sub(int x, int y) {return x-y<0 ? x-y+M : x-y;}
inline int mul(int x, int y) {return 1LL * x * y % M;}
template<class ...Args> inline int mul(int x, int y, Args... args) {return mul(mul(x, y), args...);}
inline void inc(int &x, int y=1) {x += y; if(x >= M) x -= M;}
inline void dec(int &x, int y=1) {x -= y; if(x < 0) x += M;}
inline int power(int x, int y){
  int res = 1;
  for(; y; y>>=1, x = mul(x, x)) if(y & 1) res = mul(res, x);
  return res;
}
inline int inv(int x){return power(x, M - 2);}

const int N = 200005;
int tr[N];
int cnt[N];
int n, tot = 0, totc = 0;
void modify(int p, int v) {
  inc(tot, v); ++totc;
  for (; p <= n; p += p & -p) inc(tr[p], v), ++cnt[p];
}
pair<int, int> query(int p) {
  ll s = 0;
  int c = 0;
  for (; p; p ^= p & -p) s += tr[p], c += cnt[p];
  return make_pair(int(s % M), c);
}

int p[N], Pk[N], iPk[N];

int main() {
  int k;
  read(n, k);
  for (int i = 1; i <= n; ++i)
    read(p[i]);
  int s1 = mul(k, k - 1, inv(4)), s2 = 0;
  Pk[0] = 1; iPk[0] = 1;
  Pk[1] = mul(k - 1, inv(k)); iPk[1] = inv(Pk[1]);
  for (int i = 2; i <= n; ++i) Pk[i] = mul(Pk[i - 1], Pk[1]);
  for (int i = 2; i <= n; ++i) iPk[i] = mul(iPk[i - 1], iPk[1]);
  for (int i = 1; i <= k; ++i)
    modify(p[i], iPk[k]);
  for (int i = k + 1; i <= n; ++i) {
    pair<int, int> q = query(p[i] - 1);
    int lt = q.first, gt = sub(tot, lt);
    int gtc = totc - q.second;
    inc(s2, mul(lt, Pk[i]));
    inc(s2, sub(add(gtc, gtc), mul(gt, Pk[i])));
    modify(p[i], iPk[i]);
  }
  write(add(s1, mul(s2, (M + 1) / 2))), endl();
  return 0;
}
```