#include #include using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) using mint = atcoder::modint998244353; const int MOD=998244353; const int MAX_N=2e5; vector fac(MAX_N+1,1); vector finv(MAX_N+1,1); vector inv(MAX_N+1,1); void comb_setup(){ for(int i=2;i<=MAX_N;i++){ fac.at(i)=(fac.at(i-1)*i)%MOD; inv.at(i)=MOD-(inv.at(MOD%i)*(MOD/i))%MOD; finv.at(i)=(finv.at(i-1)*inv.at(i))%MOD; } } ll comb(int n,int k){ if(n>n; vector p(n); rep(i,n) cin>>p.at(i); rep(i,n) p.at(i)--; vector lm(n),rm(n); { atcoder::fenwick_tree ft(n); rep(i,n){ lm.at(i)=ft.sum(0,p.at(i)); ft.add(p.at(i),1); } } { atcoder::fenwick_tree ft(n); for(int i=n-1;i>=0;i--){ rm.at(i)=ft.sum(0,p.at(i)); ft.add(p.at(i),1); } } mint ans=0; rep(i,n){ mint tmp=comb(i-lm.at(i)+rm.at(i),rm.at(i)); tmp*=comb(lm.at(i)+n-1-i-rm.at(i),lm.at(i)); ans+=tmp; } cout<