#include <bits/stdc++.h>
using namespace std;
const long long MN = 505, MOD = 1000 * 1000 * 1000 + 7;
long long a[MN], dp[MN][MN];
int32_t main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i], dp[i + 1][i + 1] = 1;
  for (long long s = 1; s < n; s++)
    for (long long l = 1; l <= n - s; l++) {
      long long r = l + s;
      dp[l][r] = dp[l + 1][r];
      for (long long i = l + 1; i < r; i++)
        if (a[i] > a[l]) (dp[l][r] += dp[l + 1][i] * dp[i][r] % MOD) %= MOD;
    }
  cout << dp[1][n];
}
