#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}


const ll MOD = 998244353;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}


struct Fenwick {
	vector<ll> fenv;

	Fenwick() : fenv() {}
	Fenwick(int n) : fenv(vector<ll>(n, 0)) {}

	void fadd(int p, ll x) {
		for(; p < (int)fenv.size(); p |= p + 1)
			fenv[p] = add(fenv[p], x);
	}
	int get(int r) {
		int res = 0;
		for(; r >= 0; r = (r & (r + 1)) - 1)
			res = add(res, fenv[r]);
		return res;
	}
	int getSum(int l, int r) {
		if (l >= r) return 0;
		return sub(get(r - 1), get(l - 1));
	}
};

const int N = 200200;
int n, k;
ll pw[N], rpw[N];
pii ord[N];

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);
	pw[0] = 1;
	pw[1] = sub(1, rev(k));
	for (int i = 2; i < N; i++)
		pw[i] = mult(pw[i - 1], pw[1]);
	rpw[1] = rev(pw[1]);
	for (int i = 2; i < N; i++)
		rpw[i] = mult(rpw[i - 1], rpw[1]);

	Fenwick F1 = Fenwick(n), F2 = Fenwick(n), F3 = Fenwick(n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		ord[i] = mp(x, i);
	}
	sort(ord, ord + n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int x = ord[i].second;
		ll sumL = F1.getSum(0, x), sumR = F1.getSum(x + 1, n);
		ll sumRevL = F2.getSum(0, x), sumRevR = F2.getSum(x + 1, n);
		ll cntL = F3.getSum(0, x), cntR = F3.getSum(x + 1, n);
		ans = add(ans, mult(rev(2), mult(sumRevL, pw[max(k - 1, x)])));
		ans = add(ans, cntR);
		ans = sub(ans, mult(rev(2), mult(sumR, rpw[max(k - 1, x)])));
		F1.fadd(x, pw[max(k - 1, x)]);
		F2.fadd(x, rpw[max(k - 1, x)]);
		F3.fadd(x, 1);
	}
	printf("%lld\n", ans);

	return 0;
}

### Prompt

Your task is to create 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 <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}


const ll MOD = 998244353;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}


struct Fenwick {
	vector<ll> fenv;

	Fenwick() : fenv() {}
	Fenwick(int n) : fenv(vector<ll>(n, 0)) {}

	void fadd(int p, ll x) {
		for(; p < (int)fenv.size(); p |= p + 1)
			fenv[p] = add(fenv[p], x);
	}
	int get(int r) {
		int res = 0;
		for(; r >= 0; r = (r & (r + 1)) - 1)
			res = add(res, fenv[r]);
		return res;
	}
	int getSum(int l, int r) {
		if (l >= r) return 0;
		return sub(get(r - 1), get(l - 1));
	}
};

const int N = 200200;
int n, k;
ll pw[N], rpw[N];
pii ord[N];

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);
	pw[0] = 1;
	pw[1] = sub(1, rev(k));
	for (int i = 2; i < N; i++)
		pw[i] = mult(pw[i - 1], pw[1]);
	rpw[1] = rev(pw[1]);
	for (int i = 2; i < N; i++)
		rpw[i] = mult(rpw[i - 1], rpw[1]);

	Fenwick F1 = Fenwick(n), F2 = Fenwick(n), F3 = Fenwick(n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		ord[i] = mp(x, i);
	}
	sort(ord, ord + n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int x = ord[i].second;
		ll sumL = F1.getSum(0, x), sumR = F1.getSum(x + 1, n);
		ll sumRevL = F2.getSum(0, x), sumRevR = F2.getSum(x + 1, n);
		ll cntL = F3.getSum(0, x), cntR = F3.getSum(x + 1, n);
		ans = add(ans, mult(rev(2), mult(sumRevL, pw[max(k - 1, x)])));
		ans = add(ans, cntR);
		ans = sub(ans, mult(rev(2), mult(sumR, rpw[max(k - 1, x)])));
		F1.fadd(x, pw[max(k - 1, x)]);
		F2.fadd(x, rpw[max(k - 1, x)]);
		F3.fadd(x, 1);
	}
	printf("%lld\n", ans);

	return 0;
}

```