#define MD 998244353 ll@N,@A[N],x;Mint a=0;Combc;segtreet;t.malloc(N,1);rep(i,N)x=t.getSum(A[i]-1,A[i]),a+=c.C(2x+N-A[i]-i,x)*c.C(A[i]-1+i-2x,i-x),t.add(A[i],N,1);wt(a);