#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, maxn = 500;
inline int add(int a, int b) { return (a += b) >= mod ? a - mod : a; }
inline int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
inline int mul(int a, int b) { return 1LL * a * b % mod; }
inline int qpow(int a, int p) {
  int res = 1;
  for (; p; p >>= 1, a = mul(a, a))
    if (p & 1) res = mul(res, a);
  return res;
}
int n, b[maxn + 5], ans = 1, f[maxn + 5][maxn + 5];
inline int dread() {
  int x = 0;
  bool f = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar()) f ^= (ch == '-');
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 1) + (x << 3) + (ch ^ 48);
  return f ? -x : x;
}
inline void Kaslana() {
  n = dread();
  for (int i = 1; i <= n; ++i) b[i] = dread();
}
inline void Raiden() {
  for (int i = 1; i <= n; ++i) f[i][i] = 1;
  for (int i = 2; i <= n; ++i)
    for (int L = 1; L + i - 1 <= n; ++L) {
      int R = L + i - 1;
      for (int k = L + 1; k <= R; ++k) {
        if (k != R && b[L + 1] > b[k + 1]) continue;
        f[L][R] = add(f[L][R], mul(f[L + 1][k], f[k][R]));
      }
    }
}
inline void Zaychik() { printf("%d\n", f[1][n]); }
signed main() {
  Kaslana(), Raiden(), Zaychik();
  return 0;
}
