#include <bits/stdc++.h>
template <typename T>
T in() {
  char ch;
  T n = 0;
  bool ng = false;
  while (1) {
    ch = getchar();
    if (ch == '-') {
      ng = true;
      ch = getchar();
      break;
    }
    if (ch >= '0' && ch <= '9') break;
  }
  while (1) {
    n = n * 10 + (ch - '0');
    ch = getchar();
    if (ch < '0' || ch > '9') break;
  }
  return (ng ? -n : n);
}
using namespace std;
long long int dp[506][506];
int ar[506];
long long int Solve(int l, int r) {
  if (l >= r) return 1;
  long long int &res = dp[l][r];
  if (res != -1) return res;
  res = Solve(l + 1, r);
  for (int i = l + 1; i < r + 1; i++) {
    if (ar[i] > ar[l]) {
      res = (res + Solve(l + 1, i - 1) * Solve(i, r)) % 1000000007;
    }
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i++) cin >> ar[i];
  memset(dp, -1, sizeof(dp));
  cout << Solve(2, n) << endl;
  return 0;
}
