#include <bits/stdc++.h>
using namespace std;
long long dp[505][505];
int d[505];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) scanf("%d", &d[i]);
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) dp[i][i] = dp[i][i + 1] = 1;
    for (int len = 2; len < n; len++)
      for (int i = 1; i + len <= n; i++) {
        int j = i + len;
        for (int k = i + 1; k <= j; k++)
          if (k == j || d[k + 1] > d[i + 1]) {
            dp[i][j] += dp[i + 1][k] * dp[k][j];
            dp[i][j] %= 1000000007;
            ;
          }
      }
    cout << dp[1][n] << endl;
  }
}
