#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define pb push_back
#define mk make_pair
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
const int mod=998244353;
int n,m,i,j,a[200005],s[200005],s2[200005],ans;
int fac[200005],inv[200005],fi[200005],pw[200005],ipw[200005];
vector<int> v[200005];
void add(int x,int y)
{
	while(x){
		inc(s[x],y)
		s2[x]++;
		x-=(x&-x);
	}
}
int query(int x)
{
	int ss=0;
	while(x<=n){
		inc(ss,s[x])
		x+=(x&-x);
	}
	return ss;
}
int query2(int x)
{
	int ss=0;
	while(x<=n){
		ss+=s2[x];
		x+=(x&-x);
	}
	return ss;
}
int main()
{
	fac_init(200002)
	read(n);read(m);
	pw[0]=ipw[0]=1;
	pw[1]=1ll*(m-1)*inv[m]%mod;
	ipw[1]=1ll*m*inv[m-1]%mod;
	fz(i,2,n){
		pw[i]=1ll*pw[i-1]*pw[1]%mod;
		ipw[i]=1ll*ipw[i-1]*ipw[1]%mod;
	}
	fz1(i,n){
		read(a[i]); 
		v[max(1,i-m+1)].push_back(a[i]);
	}
	int s=0,c=0;
	ans=1ll*n*(n-1)/2%mod;
	fz1(i,n-m+1){
		ff(v[i],it){
			ans=(ans+(mod-i+1))%mod;
			ans=(ans+2ll*query2(*it))%mod;
			ans=(ans+2ll*(mod-pw[i])*query(*it))%mod;
		}
		ff(v[i],it){
			c++;
			inc(s,ipw[i])
			add(*it,ipw[i]);
		}
	}
	cout<<1ll*ans*inv[2]%mod<<endl;
	return 0;
}
### Prompt

Please formulate 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 <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define pb push_back
#define mk make_pair
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
const int mod=998244353;
int n,m,i,j,a[200005],s[200005],s2[200005],ans;
int fac[200005],inv[200005],fi[200005],pw[200005],ipw[200005];
vector<int> v[200005];
void add(int x,int y)
{
	while(x){
		inc(s[x],y)
		s2[x]++;
		x-=(x&-x);
	}
}
int query(int x)
{
	int ss=0;
	while(x<=n){
		inc(ss,s[x])
		x+=(x&-x);
	}
	return ss;
}
int query2(int x)
{
	int ss=0;
	while(x<=n){
		ss+=s2[x];
		x+=(x&-x);
	}
	return ss;
}
int main()
{
	fac_init(200002)
	read(n);read(m);
	pw[0]=ipw[0]=1;
	pw[1]=1ll*(m-1)*inv[m]%mod;
	ipw[1]=1ll*m*inv[m-1]%mod;
	fz(i,2,n){
		pw[i]=1ll*pw[i-1]*pw[1]%mod;
		ipw[i]=1ll*ipw[i-1]*ipw[1]%mod;
	}
	fz1(i,n){
		read(a[i]); 
		v[max(1,i-m+1)].push_back(a[i]);
	}
	int s=0,c=0;
	ans=1ll*n*(n-1)/2%mod;
	fz1(i,n-m+1){
		ff(v[i],it){
			ans=(ans+(mod-i+1))%mod;
			ans=(ans+2ll*query2(*it))%mod;
			ans=(ans+2ll*(mod-pw[i])*query(*it))%mod;
		}
		ff(v[i],it){
			c++;
			inc(s,ipw[i])
			add(*it,ipw[i]);
		}
	}
	cout<<1ll*ans*inv[2]%mod<<endl;
	return 0;
}
```