#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T x, T y) {
  if (x > y) swap(x, y);
  while (x != 0) {
    T r = y % x;
    y = x;
    x = r;
  }
  return y;
}
template <class T>
int cntbit(T s) {
  return __builtin_popcountll(s);
}
const int esp = (int)(1e9);
const double pi = acos(-1);
const int base = (int)(1e9 + 7);
int n, b[555], f[555][555], g[555];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> b[i];
  b[n + 1] = n + 1;
  for (int i = n; i >= 1; i--) {
    g[i + 1] = 1;
    int sum = 0;
    for (int j = i + 2; j <= n; j++) g[j] = 0;
    for (int j = i + 1; j <= n; j++)
      if (g[j]) {
        for (int k = j + 1; k <= n + 1; k++)
          if (b[j] < b[k])
            g[k] = (g[k] + (long long)(g[j]) * f[j][k - 1]) % base;
      }
    f[i][i] = 1;
    for (int j = i + 1; j <= n; j++) {
      for (int k = i + 1; k <= j; k++)
        f[i][j] = (f[i][j] + (long long)g[k] * f[k][j]) % base;
    }
  }
  cout << f[1][n];
  return 0;
}
