#include using namespace std; #define mod 998244353 #define ll long long int int main(){ int T=1; //cin>>T; assert(1 <= T && T <= 10); while(T--){ int n,i; cin>>n; int a[n]; int pos[n]; for(i=0;i>a[i]; pos[a[i]]=i; } int l=pos[0]; int r=pos[0]; ll ans=1; for(i=1;il){ ll z=(r-l+1)-i; ans=(ans*z)%mod; } else { l=min(l,pos[i]); r=max(r,pos[i]); } } cout<