#include <bits/stdc++.h>
using namespace std;
inline long long in() {
  long long x = 0, n = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) n = (c == '-');
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return n ? -x : x;
}
const int N = 505, MOD = 1e9 + 7;
int n;
int a[N];
long long f[N][N];
long long F(int l, int r) {
  if (f[l][r] >= 0) return f[l][r];
  if (l == r) return f[l][r] = 1;
  long long res = 0;
  for (int i = l + 1; i <= r - 1; i++)
    if (a[l] < a[i + 1]) res = (res + F(l + 1, i) * F(i + 1, r) % MOD) % MOD;
  res += F(l + 1, r);
  res %= MOD;
  if (a[l] < a[l + 1]) res += F(l + 1, r);
  res %= MOD;
  return f[l][r] = res;
}
int main() {
  memset(f, -1, sizeof(f));
  n = in();
  for (int i = 1; i <= n; i++) a[i] = in();
  if (n == 1)
    cout << 1;
  else
    cout << F(2, n);
}
