#include using namespace std; typedef long long ll; #define sci(fd) scanf("%d",&fd) #define scll(fd) scanf("%lld",&fd) #define pb push_back #define mp make_pair #define MOD 1000000007 #define PI 3.1415926535897932 #define pii pair < int,int > #define pll pair < ll,ll > #define fi first #define se second #define LOGN 20 #define MAX 1209 const ll infi=1000000000000000009; ll ar[MAX+3]; ll dp[MAX+3][MAX+3]; ll fact[MAX+3],inv[MAX+3]; ll lookup[MAX+3][MAX+3]; long long power(ll x,ll y) { if(y==0) return 1; ll temp=power(x,y/2); if(y&1) return (((temp*temp)%MOD)*(x%MOD))%MOD; return (temp*temp)%MOD; } void compute() { int i,j; fact[0]=1; for(i=1;i<=MAX;i++) fact[i]=(i*fact[i-1])%MOD; inv[MAX]=power(fact[MAX],MOD-2); for(i=MAX-1;i>=0;i--) inv[i]=((i+1)*inv[i+1])%MOD; } ll npr(ll n,ll r) { if(nar[i-1]&&(i-ci+1<=maxc)) ans=(ans+(lookup[maxc][i-ci+1]*doit(i+1,i-ci+1))%MOD)%MOD; else break; } return dp[ci][maxc]=ans; } int main() { ll i,j; compute(); for(i=0;i<=MAX;i++) { for(j=0;j<=i;j++) lookup[i][j]=npr(i,j); } scll(n); for(i=1;i<=n;i++) scll(ar[i]); memset(dp,-1,sizeof(dp)); ll ans=0; for(i=1;i<=n;i++) { if(ar[i]>ar[i-1]) ans=(ans+doit(i+1,i))%MOD; else break; } printf("%lld\n",ans); return 0; }