#include <bits/stdc++.h>
using namespace std;
const int maxn = 505, mod = 1e9 + 7;
int n, ar[maxn], dp[maxn][maxn];
int solve(int l, int r) {
  if (l >= r) return 1;
  if (dp[l][r] != -1) return dp[l][r];
  int &ret = dp[l][r];
  ret = solve(l + 1, r);
  for (int i = l + 1; i <= r; i++)
    if (ar[l] < ar[i])
      ret = (ret + 1ll * solve(l + 1, i - 1) * solve(i, r) % mod) % mod;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &ar[i]);
  memset(dp, -1, sizeof dp);
  printf("%d\n", solve(2, n));
  return 0;
}
