#include <bits/stdc++.h>
using namespace std;
int read() {
  char c;
  int sum = 0, f = 1;
  c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * f;
}
int n, b[505];
long long dp[505][505];
long long dfs(int l, int r) {
  if (dp[l][r] != -1) return dp[l][r];
  if (l == r) return dp[l][r] = 1;
  long long sum = 0;
  for (int i = l + 1; i <= r; i++) {
    if (i != r && b[l + 1] >= b[i + 1]) continue;
    sum += dfs(l + 1, i) * dfs(i, r);
    sum %= 1000000007;
  }
  return dp[l][r] = sum;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) b[i] = read();
  memset(dp, -1, sizeof(dp));
  printf("%I64d\n", dfs(1, n));
  return 0;
}
