#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long double EPS = 1e-14;
vector<int> a;
vector<vector<long long>> dp;
const long long mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < int(n); i++) cin >> a[i];
  dp.assign(n, vector<long long>(n, 0));
  for (int i = 0; i < int(n); i++) dp[i][i] = 1;
  for (int i = 0; i < int(n); i++)
    if (i < n - 1) dp[i + 1][i] = 1;
  for (int j = 1; j < n; j++) {
    for (int i = 0; i + j < n; i++) {
      dp[i][i + j] += dp[i + 1][i + j];
      for (int k = 1; k <= j; k++) {
        if (a[i] < a[i + k])
          dp[i][i + j] =
              (dp[i][i + j] + dp[i + 1][i + k - 1] * dp[i + k][i + j]) % mod;
      }
    }
  }
  cout << ((n == 1) ? 1 : dp[1][n - 1]);
  return 0;
}
