#include <bits/stdc++.h>
const int N = 510;
const int mod = (int)1e9 + 7;
int n, a[N];
long long dp[N][N];
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    memset(dp, 0, sizeof(dp));
    dp[n][n] = 1;
    a[n + 1] = 10000;
    for (int i = n - 1; i >= 1; i--) {
      dp[i][i] = 1;
      for (int j = i + 1; j <= n; j++) {
        for (int k = i + 1; k <= j; k++) {
          if (a[i + 1] < a[k + 1] || k == j) {
            dp[i][j] = (dp[i][j] + dp[i + 1][k] * dp[k][j]) % mod;
          }
        }
      }
    }
    printf("%I64d\n", dp[1][n]);
  }
  return 0;
}
