#include #include #include #include #include #include using namespace std; #define lli long long #define N 1200 #define MODM (int)(1e9+7) int n; int a[N+1]; int l[N+1]; lli dp[N+1][N+1]; lli fact[N+1], invFact[N+1]; lli fastpow(lli a, int n, lli temp) { if (n==0) return 1; if (n==1) return(a*temp)%MODM; if (n%2) temp = (temp*a)%MODM; return fastpow((a*a)%MODM, n/2, temp); } lli solve(int idx, int lastSize) { if (idx == n) return 1; lli &ans = dp[idx][lastSize]; if (ans != -1) return ans; ans = 0; for (int i = 1; i<=min(lastSize, l[idx]); i++) { ans = (ans + ((fact[lastSize]*invFact[lastSize-i])%MODM * solve(idx + i, i))%MODM)%MODM; } return ans; } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ cin>>n; for(int i=0;i>a[i]; l[n-1] = 1; for(int i=n-2;i>=0;i--) { if(a[i] < a[i+1]) l[i] = l[i+1]+1; else l[i] = 1; } fact[0] = invFact[0] = 1; for(int i=1;i<=n;i++) { fact[i] = (i*fact[i-1])%MODM; invFact[i] = (fastpow(i, MODM-2, 1)*invFact[i-1])%MODM; } lli ans = 0; memset(dp, -1, sizeof(dp)); for(int i=1;i<=l[0];i++) { ans = (ans + solve(i, i))%MODM; } cout<