/*
_/_/_/_/    _/_/_/_/_/  _/_/_/
_/      _/      _/    _/      _/
_/      _/      _/    _/      _/
_/      _/      _/    _/      _/
_/      _/      _/    _/  _/  _/
_/      _/  _/  _/    _/    _/_/
_/_/_/_/      _/_/     _/_/_/_/_/

_/_/_/_/    _/    _/  _/      _/
_/      _/   _/  _/   _/_/  _/_/
_/      _/    _/_/    _/ _/_/ _/
_/      _/     _/     _/  _/  _/
_/      _/    _/_/    _/      _/
_/      _/   _/  _/   _/      _/
_/_/_/_/    _/    _/  _/      _/

_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/         _/     _/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/     _/_/_/_/_/ _/_/_/_/_/

_/_/_/_/_/ _/_/_/_/_/ _/_/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/         _/     _/_/_/_/
    _/         _/     _/
    _/         _/     _/
    _/     _/_/_/_/_/ _/_/_/_/_/
*/
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v)
    is >> x;
  return is;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int P = 998244353;

int norm(int x) { return x >= P ? (x - P) : x; }

void add(int &x, int y) { if ((x += y) >= P) x -= P; }

void sub(int &x, int y) { if ((x -= y) < 0) x += P; }

void exGcd(int a, int b, int &x, int &y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  exGcd(b, a % b, y, x);
  y -= a / b * x;
}

int inv(int a) {
  int x, y;
  exGcd(a, P, x, y);
  return norm(x + P);
}

const int N = 200010;

struct Node {
  int p, s;
} Q[N << 2];

void apply(int o, int x) {
  Q[o].p = Q[o].p * (ll) x % P;
  Q[o].s = Q[o].s * (ll) x % P;
}

void pd(int o) {
  if (Q[o].p != 1) {
    apply(o << 1, Q[o].p);
    apply(o << 1 | 1, Q[o].p);
    Q[o].p = 1;
  }
}

void upd(int o) {
  Q[o].s = norm(Q[o << 1].s + Q[o << 1 | 1].s);
}

void sval(int o, int l, int r, int k, int x) {
  if (l == r) {
    Q[o].s = x;
    return;
  }
  pd(o);
  int mid = (l + r) >> 1;
  if (k <= mid)sval(o << 1, l, mid, k, x); else sval(o << 1 | 1, mid + 1, r, k, x);
  upd(o);
}

int qry(int o, int l, int r, int ql, int qr) {
  if (l == ql && r == qr)return Q[o].s;
  pd(o);
  int mid = (l + r) >> 1;
  if (qr <= mid)return qry(o << 1, l, mid, ql, qr);
  if (ql > mid)return qry(o << 1 | 1, mid + 1, r, ql, qr);
  return norm(qry(o << 1, l, mid, ql, mid) + qry(o << 1 | 1, mid + 1, r, mid + 1, qr));
}

int fw[N];

int n;

void ad(int k, int x) {
  for (; k <= n; k += k & -k)fw[k] += x;
}

int qry(int k) {
  int ret = 0;
  for (; k; k &= k - 1)ret += fw[k];
  return ret;
}

int p[N];

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> p[i];
  int ans = 0;
  int I2 = inv(2);
  for (int i = 1; i < k; ++i) {
    ad(p[i], 1);add(ans, (i - 1) * (ll) I2 % P);
    sval(1, 1, n, p[i], 1);
  }
  int mu = (k - 1LL) * inv(k) % P;
  for (int i = k; i <= n; ++i) {
    int lcnt = qry(p[i]);
    int lsum = qry(1, 1, n, 1, p[i]);
    int rcnt = i - 1 - lcnt, rsum = norm(P + (k - 1) - lsum);
    add(ans, (k - 1) * (ll) I2 % P);
    add(ans, norm(P + rcnt - rsum));
    ad(p[i], 1);
    sval(1, 1, n, p[i], 1);
    apply(1, mu);
  }
  cout << ans << '\n';

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  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 <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v)
    is >> x;
  return is;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int P = 998244353;

int norm(int x) { return x >= P ? (x - P) : x; }

void add(int &x, int y) { if ((x += y) >= P) x -= P; }

void sub(int &x, int y) { if ((x -= y) < 0) x += P; }

void exGcd(int a, int b, int &x, int &y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  exGcd(b, a % b, y, x);
  y -= a / b * x;
}

int inv(int a) {
  int x, y;
  exGcd(a, P, x, y);
  return norm(x + P);
}

const int N = 200010;

struct Node {
  int p, s;
} Q[N << 2];

void apply(int o, int x) {
  Q[o].p = Q[o].p * (ll) x % P;
  Q[o].s = Q[o].s * (ll) x % P;
}

void pd(int o) {
  if (Q[o].p != 1) {
    apply(o << 1, Q[o].p);
    apply(o << 1 | 1, Q[o].p);
    Q[o].p = 1;
  }
}

void upd(int o) {
  Q[o].s = norm(Q[o << 1].s + Q[o << 1 | 1].s);
}

void sval(int o, int l, int r, int k, int x) {
  if (l == r) {
    Q[o].s = x;
    return;
  }
  pd(o);
  int mid = (l + r) >> 1;
  if (k <= mid)sval(o << 1, l, mid, k, x); else sval(o << 1 | 1, mid + 1, r, k, x);
  upd(o);
}

int qry(int o, int l, int r, int ql, int qr) {
  if (l == ql && r == qr)return Q[o].s;
  pd(o);
  int mid = (l + r) >> 1;
  if (qr <= mid)return qry(o << 1, l, mid, ql, qr);
  if (ql > mid)return qry(o << 1 | 1, mid + 1, r, ql, qr);
  return norm(qry(o << 1, l, mid, ql, mid) + qry(o << 1 | 1, mid + 1, r, mid + 1, qr));
}

int fw[N];

int n;

void ad(int k, int x) {
  for (; k <= n; k += k & -k)fw[k] += x;
}

int qry(int k) {
  int ret = 0;
  for (; k; k &= k - 1)ret += fw[k];
  return ret;
}

int p[N];

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> p[i];
  int ans = 0;
  int I2 = inv(2);
  for (int i = 1; i < k; ++i) {
    ad(p[i], 1);add(ans, (i - 1) * (ll) I2 % P);
    sval(1, 1, n, p[i], 1);
  }
  int mu = (k - 1LL) * inv(k) % P;
  for (int i = k; i <= n; ++i) {
    int lcnt = qry(p[i]);
    int lsum = qry(1, 1, n, 1, p[i]);
    int rcnt = i - 1 - lcnt, rsum = norm(P + (k - 1) - lsum);
    add(ans, (k - 1) * (ll) I2 % P);
    add(ans, norm(P + rcnt - rsum));
    ad(p[i], 1);
    sval(1, 1, n, p[i], 1);
    apply(1, mu);
  }
  cout << ans << '\n';

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}

```