#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const long long mod = 1000000007;
int b[N];
long long d[N][N];
long long f(int L, int R) {
  if (L == R) return 1;
  long long &ans = d[L][R];
  if (ans < 0) {
    ans = 0;
    for (int M = L + 1; M <= R; M++)
      if (M == R || b[L + 1] < b[M + 1])
        ans = (ans + f(L + 1, M) * f(M, R)) % mod;
  }
  return ans;
}
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) cin >> b[i];
    memset(d, -1, sizeof d);
    cout << f(1, n) << endl;
  }
  return 0;
}
