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