#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1000000000 + 7;
const int Max = 555;
int n;
int a[Max];
long long dp[Max][Max];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) dp[1][i] = 1;
  for (int i = 2; i <= n - 1; i++) {
    for (int j = 2; j <= n - i + 1; j++) {
      dp[i][j] = dp[i - 1][j + 1];
      if (a[j] < a[j + 1]) {
        dp[i][j] += dp[i - 1][j + 1];
        dp[i][j] %= Mod;
      }
      for (int z = j + 2; z <= j + i - 1; z++) {
        if (a[j] < a[z]) {
          long long push =
              dp[(z - 1) - (j + 1) + 1][j + 1] * dp[(j + i - 1) - z + 1][z];
          push %= Mod;
          dp[i][j] += push;
          dp[i][j] %= Mod;
        }
      }
    }
  }
  if (n == 1)
    cout << "1" << endl;
  else
    cout << dp[n - 1][2] << endl;
  return 0;
}
