#include <bits/stdc++.h>
using namespace std;
const int MAXN = 510, mod = 1000000007;
int niz[MAXN];
int n;
int dp[MAXN][MAXN];
int rek(int a, int b) {
  if (a >= b) return 1;
  int &ret = dp[a][b];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = a + 1; i <= b; i++)
    if (niz[a] < niz[i])
      ret =
          ((long long int)ret + (long long int)rek(a + 1, i - 1) * rek(i, b)) %
          mod;
  ret = ((long long int)ret + (long long int)rek(a + 1, b)) % mod;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &niz[i]);
  memset(dp, -1, sizeof(dp));
  printf("%d\n", rek(2, n));
  return 0;
}
