#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500 + 1;
const int mod = 1e9 + 7;
void madd(int& a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mul(int a, int b) { return ((long long)a * b) % mod; }
int mpow(int a, int n) {
  int r = 1;
  while (n > 0) {
    if (n & 1) r = mul(r, a);
    a = mul(a, a);
    n >>= 1;
  }
  return r;
}
int N;
int A[MAX_N];
int D[MAX_N][MAX_N];
int calcd(int, int);
int calcf(int i, int j) { return calcd(i + 1, j); }
int calcd(int i, int j) {
  if (i - 1 == j) return 1;
  if (D[i][j] != -1) return D[i][j];
  D[i][j] = calcf(i, j);
  for (int k = i + 1; k <= j; k++)
    if (A[i] < A[k]) madd(D[i][j], mul(calcf(i, k - 1), calcd(k, j)));
  return D[i][j];
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", A + i);
  memset(D, -1, sizeof D);
  printf("%d\n", calcf(0, N - 1));
  return 0;
}
