#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 505;
int a[MAX], dp[MAX][MAX];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i <= n; i++) dp[i][i] = 1;
  for (int i = 0; i < n; i++) dp[i][i + 1] = 1;
  for (int len = 2; len <= n; len++)
    for (int l = 0; l + len <= n; l++) {
      int r = l + len;
      dp[l][r] = dp[l + 1][r];
      for (int i = l + 1; i < r; i++)
        if (a[l] < a[i])
          dp[l][r] = (dp[l][r] + 1LL * dp[l + 1][i] * dp[i][r]) % MOD;
    }
  cout << dp[1][n] << endl;
  return 0;
}
