#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500 + 5;
const long long MOD = 1e9 + 7;
long long dp[MAXN][MAXN];
long long dp2[MAXN][MAXN];
int b[MAXN];
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
  }
  for (int i = 1; i <= n; i++) {
    dp[i][i] = 1;
    dp2[i][i] = 1;
  }
  for (int len = 2; len <= n; len++) {
    for (int l = 1; l + len - 1 <= n; l++) {
      int r = l + len - 1;
      dp[l][r] = dp2[l + 1][r];
      dp2[l][r] = dp[l][r];
      for (int k = l; k < r; k++) {
        if (b[k + 1] <= b[l]) continue;
        long long cur = (dp[l][k] * dp2[k + 1][r]) % MOD;
        dp2[l][r] = (dp2[l][r] + cur) % MOD;
      }
    }
  }
  cout << dp[1][n];
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
