#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int MAXN = 1000;
int dp[MAXN][MAXN];
int all[MAXN][MAXN];
int b[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) dp[i][i] = all[i][i] = 1;
  for (int len = 1; len < n - 1; len++)
    for (int l = 1; l + len < n; l++) {
      int r = l + len;
      dp[l][r] = all[l + 1][r];
      all[l][r] = dp[l][r];
      for (int k = l; k < r; k++) {
        if (b[l] < b[k + 1]) {
          all[l][r] += ((long long)dp[l][k] * all[k + 1][r]) % mod;
          if (all[l][r] >= mod) all[l][r] -= mod;
        }
      }
    }
  cout << all[1][n - 1];
  return 0;
}
