#include <bits/stdc++.h>
using namespace std;
unsigned long long dp[505][505];
int num[505];
unsigned long long f(int l, int r) {
  if (l > r) return 1;
  if (dp[l][r] != -1) return dp[l][r];
  dp[l][r] = 0;
  for (int i = l; i <= r; i++)
    if (i == r || num[l] < num[i + 1])
      dp[l][r] = (dp[l][r] + f(l + 1, i) * f(i + 1, r)) % 1000000007;
  return dp[l][r];
}
int main() {
  memset(dp, -1, sizeof(dp));
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &num[i]), dp[i][i] = 1;
  printf("%I64d\n", f(1, n - 1));
  return 0;
}
