#include <bits/stdc++.h>
const int MAXN = 510;
const int mod = 1e9 + 7;
long long int dp[MAXN][MAXN];
int n;
int a[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n + 1; i++) {
    dp[i][i] = 1;
    dp[i][i - 1] = 1;
  }
  for (int l = 2; l <= n - 1; l++) {
    for (int i = 1; i + l - 1 <= n; i++) {
      int j = i + l - 1;
      dp[i][j] = 0;
      for (int k = 2; k <= j; k++) {
        if (a[k + 1] <= a[i] && k != j) continue;
        dp[i][j] += dp[i + 1][k] * dp[k + 1][j];
        dp[i][j] %= mod;
      }
    }
  }
  printf("%I64d\n", dp[2][n]);
  return 0;
}
