#include <bits/stdc++.h>
using namespace std;
int b[501];
long long int dp[501][501][2];
int main() {
  memset(dp, 0, sizeof dp);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  for (int i = 0; i < n; i++) {
    dp[i][i][0] = 1;
    dp[i][i][1] = 1;
  }
  for (int sz = 1; sz < n; sz++) {
    for (int i = 0; i < n - sz; i++) {
      int j = i + sz;
      dp[i][j][1] = dp[i + 1][j][0];
      dp[i][j][0] = dp[i][j][1];
      for (int k = i; k <= j - 1; k++) {
        if (b[k + 1] > b[i]) {
          dp[i][j][0] =
              (dp[i][j][0] + dp[i][k][1] * dp[k + 1][j][0]) % 1000000007;
        }
      }
    }
  }
  printf("%lld\n", dp[0][n - 1][1]);
}
