#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 550;
struct DDF {
  int n;
  int v[maxn];
  int dp[maxn][maxn];
  int dfs(int l, int r) {
    if (l >= r) return dp[l][r] = 1;
    if (~dp[l][r]) return dp[l][r];
    long long ans = dfs(l + 1, r);
    for (int i = l + 1; i <= r; i++) {
      if (v[l + 1] < v[i + 1]) {
        ans += 1LL * dfs(l + 1, i - 1) * (dfs(i, r));
        ans %= mod;
      }
    }
    return dp[l][r] = ans;
  }
  void solve() {
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
    printf("%d\n", dfs(1, n));
  }
} solver;
int main() {
  solver.solve();
  return 0;
}
