#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const int MOD = 1e9 + 7;
long long dp[555][555];
int a[555];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) dp[i][i] = 1;
  for (int r = 2; r <= n; ++r) {
    for (int l = 1; l <= r - 1; ++l) {
      dp[l][r] = dp[l][r - 1] % MOD;
      for (int i = l + 1; i <= r - 1; ++i) {
        dp[l][r] += (dp[l][i] * dp[i][r - 1] * (a[r] > a[i])) % MOD;
        dp[l][r] %= MOD;
      }
    }
  }
  cout << dp[1][n];
  return 0;
}
