#include #define REP(i,n) for(int i=0,i##_len=int(n);i>N; vector a(N+1,-1e9-1); REP(i, N) cin >> a[i+1]; vector> dp(N+1); dp[0]=make_pair(1,1); REP(i,N) REP(j,i+1){ if(a[j]dp[i+1].second){ dp[i+1]=dp[j]; dp[i+1].second++; } else if(dp[j].second+1==dp[i+1].second){ dp[i+1].first+=dp[j].first; dp[i+1].first%=mod; } } } pair ans=make_pair(0,0); REP(i,N+1){ if(dp[i].second>ans.second){ ans=dp[i]; } else if(dp[i].second==ans.second){ ans.first+=dp[i].first; } } cout<