#include #include using namespace std; typedef long long ll; ll n,seg[400010],INF = 1000000000000; void update(int p,ll val){ for(seg[p += n] += val;p>1;p>>=1){ seg[p>>1] = seg[p] + seg[p^1]; } } ll query(int l,int r){ ll res = 0; for(l += n,r += n; l>=1,r>>=1){ if(l&1) res += seg[l++]; if(r&1) res += seg[--r]; } return res; } int a[200010],b[200010] = {}; map mp; constexpr ll mod = 998244353; const int MX = 1000100; ll f[MX],inv[MX],fi[MX]; void solve(){ inv[1] = 1; for(int i=2;i> n; for(i=0;i> a[i]; mp[a[i]] = 1; } int cnt = 0; for(auto x:mp){ mp[x.first] = cnt; cnt++; } for(i=0;i=0;i--){ (sum += b[i]*sum1%mod) %=mod; (sum1 += b[i]) %= mod; } solve(); ll ans = 0; for(i=1;i<=n;i++) (ans += i*i%mod*(i - 1)%mod) %= mod; (ans *= sum) %= mod; (ans *= pw(2*n*n,mod - 2)) %= mod; ll ans1 = 0; for(i=1;i<=n;i++) (ans1 += i*(i - 1)%mod) %= mod; (ans1 *= tento) %= mod; (ans1 *= pw(n*(n - 1),mod -2)) %= mod; (ans += ans1) %= mod; ll ans2 = ans; for(i=1;i<=n;i++) (ans *= nck(n,i)) %= mod; cout << ans << endl; }