#include <bits/stdc++.h>
using namespace std;
const int MAXN = 505, MOD = 1e9 + 7;
long long dp[MAXN][MAXN];
int n, a[MAXN];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], dp[i][i + 1] = 1, dp[i][i] = 1;
  dp[n][n] = 1;
  for (int l = 2; l < n; l++)
    for (int i = 1; i + l <= n; i++) {
      dp[i][i + l] = dp[i + 1][i + l];
      for (int j = i + 1; j < i + l; j++)
        if (a[j] > a[i])
          dp[i][i + l] += dp[i + 1][j] * dp[j][i + l], dp[i][i + l] %= MOD;
    }
  cout << dp[1][n];
}
