#include <bits/stdc++.h>
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
bool exmax(T &a, T b) {
  return (b > a) ? (a = b) || 1 : 0;
}
template <typename T>
bool exmin(T &a, T b) {
  return (b < a) ? (a = b) || 1 : 0;
}
using namespace std;
int g[510];
long long f[510][510];
long long dfs(int l, int r) {
  if (f[l][r] != -1) return f[l][r];
  if (l == r) return f[l][r] = 1LL;
  long long &ret = f[l][r];
  ret = 0;
  for (int i = l + 1; i <= r; i++)
    if (i == r || g[i + 1] > g[l + 1])
      ret = (ret + dfs(l + 1, i) * dfs(i, r)) % 1000000007;
  return ret;
}
int main() {
  int n;
  cin >> n;
  for (__typeof(n) i = 0; i < (n); i++) cin >> g[i];
  memset(f, 0xff, sizeof(f));
  cout << dfs(0, n - 1) << endl;
  return 0;
}
