#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 510;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 500;
long long dp[maxn][maxn];
long long a[maxn];
int main() {
  long long n;
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  long long v;
  cin >> v;
  n--;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    dp[i][i] = 1;
  }
  for (long long t = 2; t <= n; t++) {
    for (long long l = 0; l + t <= n; l++) {
      long long r = l + t - 1;
      dp[l][r] = dp[l + 1][r];
      for (long long m = l + 1; m <= r; m++) {
        if (a[m] > a[l]) {
          if (l + 1 > m - 1) {
            dp[l][r] = (dp[l][r] + dp[m][r]) % mod;
          } else {
            dp[l][r] = (dp[l][r] + dp[l + 1][m - 1] * dp[m][r]) % mod;
          }
        }
      }
    }
  }
  cout << dp[0][n - 1];
}
