#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long lnf = 0x3f3f3f3f3f3f3f3f;
const double dnf = 1e18;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int maxm = 100100;
const int up = 100000;
const int hashp = 13331;
const int maxn = 510;
long long dp[maxn][maxn], b[maxn];
long long dfs(int l, int r) {
  if (dp[l][r] != -1) return dp[l][r];
  if (l == r) return dp[l][r] = 1;
  dp[l][r] = 0;
  for (int k = l + 1; k <= r; k++) {
    if (b[l + 1] < b[k + 1] || k == r)
      dp[l][r] = (dp[l][r] + dfs(l + 1, k) * dfs(k, r)) % mod;
  }
  return dp[l][r];
}
int main(void) {
  memset(dp, -1, sizeof(dp));
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
  printf("%lld\n", dfs(1, n));
  return 0;
}
