#include <bits/stdc++.h>
using namespace std;
unsigned long long dp[510][510];
int n;
int c[510];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++) dp[i][i] = dp[i][i + 1] = 1;
  for (int i = n; i >= 1; i--)
    for (int j = i + 2; j <= n; j++) {
      dp[i][j] = 0;
      for (int k = i + 1; k <= j; k++)
        if (c[i + 1] < c[k + 1] || k == j) {
          dp[i][j] += (dp[i + 1][k] * dp[k][j]) % 1000000007;
          dp[i][j] %= 1000000007;
        }
    }
  cout << dp[1][n];
  return 0;
}
