#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5e2 + 10, MOD = 1e9 + 7;
int n;
int Arr[MAX_N];
int dp[MAX_N][MAX_N];
int _sum(int a, int b) {
  int c = a + b;
  if (MOD <= c) c -= MOD;
  return c;
}
int _mul(int a, int b) {
  int c = 1LL * a * b % MOD;
  return c;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> Arr[i];
  Arr[n] = n + 1;
  for (int i = 0; i < n; i++) {
    dp[i][i] = 1;
    dp[i][i + 1] = 1;
  }
  dp[n][n] = 1;
  for (int len = 2; len <= n; len++)
    for (int l = 0; l + len <= n; l++) {
      int r = l + len;
      for (int j = l; j < r; j++)
        if (Arr[l] <= Arr[j + 1] || j + 1 == r)
          dp[l][r] = _sum(dp[l][r], _mul(dp[l + 1][j + 1], dp[j + 1][r]));
    }
  cout << dp[1][n] << "\n";
  return 0;
}
