#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
vector<int> b;
int f[503][503];
int g2(int i, int j) {}
int g(int i, int j) {
  if (i == j) return 1;
  int& res = f[i][j];
  if (res != -1) return res;
  res = g(i + 1, j);
  for (int k = i + 2; k <= j; ++k) {
    if (b[k] > b[i + 1]) {
      res += g(i + 1, k - 1) * (long long)g(k - 1, j) % MOD;
      if (res >= MOD) res -= MOD;
    }
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  b.resize(n);
  for (int i = 0; i < n; ++i) cin >> b[i];
  memset(f, -1, sizeof(f));
  cout << g(0, (int)(b.size()) - 1) << '\n';
  return 0;
}
