#include <bits/stdc++.h>
using namespace std;
template <class T>
T nextInt() {
  T x = 0, p = 1;
  char c;
  do {
    c = getchar();
  } while (c <= 32);
  if (c == '-') {
    p = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * p;
}
const int maxn = 505;
const long long P = (long long)1e9 + 7;
void add(long long& x, long long y) {
  x += y;
  if (x >= P) x -= P;
}
long long multi(long long x, long long y) { return (x * y) % P; }
long long f[maxn][maxn], ff[maxn][maxn];
bool c[maxn][maxn], cc[maxn][maxn];
int b[maxn], n;
long long dp(int, int);
long long dpp(int, int);
long long dpp(int l, int r) {
  if (cc[l][r]) return ff[l][r];
  if (l > r) return 1LL;
  cc[l][r] = true;
  for (int i = l; i <= r; i++) {
    if (i + 1 > r || b[i + 1] > b[l]) {
      add(ff[l][r], multi(dp(l, i), dpp(i + 1, r)));
    }
  }
  return ff[l][r];
}
long long dp(int l, int r) {
  if (c[l][r]) return f[l][r];
  c[l][r] = true;
  return f[l][r] = dpp(l + 1, r);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> b[i];
  cout << dp(1, n) << "\n";
  return 0;
}
