#include <bits/stdc++.h>
using namespace std;
int n, d[505], dp[505][505];
int fun(int b, int e) {
  if (b == e) return 1;
  if (dp[b][e] != -1) return dp[b][e];
  int res = fun(b + 1, e);
  for (int i = b + 1; i <= e; i++)
    if (d[i] > d[b])
      res = (res + (b == i - 1 ? 1 : fun(b + 1, i - 1)) * 1ll * fun(i, e)) %
            1000000007;
  return dp[b][e] = res;
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &d[i]);
  printf("%d\n", n == 1 ? 1 : fun(2, n));
}
