#include <bits/stdc++.h>
using namespace std;
long long dp[505][505];
int a[505];
long long dfs(int l, int r) {
  if (l == r) return dp[l][r] = 1;
  if (~dp[l][r]) return dp[l][r];
  long long ret = dfs(l + 1, r);
  for (int i = l + 1; i < r; i++) {
    if (a[i + 1] >= a[l + 1])
      ret = (ret + dfs(l + 1, i) * dfs(i, r)) % 1000000007;
  }
  return dp[l][r] = ret % 1000000007;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  memset(dp, -1, sizeof(dp));
  cout << dfs(1, n) << endl;
  return 0;
}
