#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
  return x * f;
}
const int N = 505, mod = 1e9 + 7;
inline int inc(int x, int y) {
  x += y - mod;
  return x + (x >> 31 & mod);
}
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline void Inc(int &x, int y) { x = inc(x, y); }
int n, a[N], f[N][N];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), f[i][i] = 1;
  for (int i = 1; i <= n + 1; i++) f[i][i - 1] = 1;
  for (int len = 2; len < n; len++)
    for (int l = 1; l <= n - len + 1; l++) {
      int r = l + len - 1;
      f[l][r] = f[l + 1][r];
      for (int k = l + 1; k <= r; k++)
        if (a[k] > a[l]) Inc(f[l][r], mul(f[l + 1][k - 1], f[k][r]));
    }
  printf("%d\n", f[2][n]);
  return 0;
}
