#include <bits/stdc++.h>
using namespace std;
int a[505];
const int modo = 1000000007;
int dp[505][505];
int n;
void dfs(int x, int y) {
  if (dp[x][y] != -1) return;
  if (x == y) {
    dp[x][y] = 1;
    return;
  }
  int j;
  dp[x][y] = 0;
  for (j = x + 1; j < y; j++) {
    if (a[j] > a[x]) {
      dfs(x + 1, j);
      dfs(j, y);
      dp[x][y] = (dp[x][y] + (long long)dp[x + 1][j] * dp[j][y]) % modo;
    }
  }
  dfs(x + 1, y);
  dp[x][y] = (dp[x][y] + dp[x + 1][y]) % modo;
}
int main() {
  scanf("%d", &n);
  int i;
  memset(dp, -1, sizeof(dp));
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  dfs(1, n);
  printf("%d\n", dp[1][n]);
  return 0;
}
