#include #include #include #define rep(i,a,n) for(int i=a;i<=n;++i) using namespace std; const int mx = (int)1e5; const int mod = (int)1e9+7; int n, a[mx], dp[1222][1222]; int sum[1220]; int ans = 0; int main() { sum[1] = 1; dp[1][1] = 1; cin >> n; rep(i,1,n) cin >> a[i]; rep(i,2,n) { int j = i-1; while(j >= 1 && a[j] < a[i]) --j; if(!j) { dp[i][1] = 1; rep(k,2,n) dp[i][k] = (dp[i][k]+sum[k-1])%mod; } else rep(k,2,n) if(dp[j][k-1]) dp[i][k] = (dp[i][k]+sum[k-1])%mod; rep(k,1,n) sum[k] = (sum[k]+dp[i][k])%mod; } rep(i,1,n) ans = (ans+dp[n][i])%mod; cout << ans; return 0; }