#include using namespace std; #define forn(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define forn1(i, n) for(int i = 1; i <= int(n);++(i)) #define rforn(i,n) for(int (i)=n-1;(i)>=(int)(0);--(i)) #define forlu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #define rforlu(i,l,u) for(int (i)=(int)(u-1);(i)>=(int)(l);--(i)) const int MAXN = 1200; int dp[MAXN + 1][2]; inline void init() { memset(dp, 0, sizeof(int) * (MAXN + 1) * (2)); } const int MOD = 1000 * 1000 * 1000 + 7; inline int mod_add(int lhs, int rhs) { return ((lhs % MOD) + (rhs % MOD)) % MOD; } int main() { int n; cin >> n; std::vector v(1); copy_n(istream_iterator(cin), n, back_inserter(v)); init(); dp[1][1] = 1; int is = 1; for (int i = 2; i <= n; ++i) { for (int j = is+1; j <= i; ++j) { dp[i%2][j] = dp[!(i%2)][j - 1]; } if (v[i] < v[i - 1]) { dp[i % 2][is] = 0; is++; } else dp[i % 2][is] = mod_add(dp[!(i % 2)][is], 1); } int ans = 0; if (is == 1) { ans += 1; is++; } forlu(i, is, n+1) { ans = mod_add(ans, dp[n%2][i]); } cout << ans << '\n'; return 0; }