#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9;
const int mod = 1000000007;
int N;
int a[505];
int dp[2][505][505];
int solve(bool rt, int l, int r) {
  if (dp[rt][l][r] != -1) return dp[rt][l][r];
  if (l > r) return 0;
  if (l == r) {
    return dp[rt][l][r] = 1;
  }
  if (rt == 0) {
    return dp[rt][l][r] = solve(1, l + 1, r);
  }
  int ans = solve(0, l, r);
  for (int k = (l); k < (r); k++) {
    if (a[l] > a[k + 1]) continue;
    int sol = solve(0, l, k);
    sol = (long long)sol * solve(1, k + 1, r) % mod;
    ans = (ans + sol) % mod;
  }
  return dp[rt][l][r] = ans;
}
int main() {
  cin >> N;
  for (int i = (0); i < (N); i++) scanf("%d", a + i);
  memset(dp, -1, sizeof(dp));
  solve(0, 0, N - 1);
  cout << dp[0][0][N - 1] << endl;
  return 0;
}
