#include <bits/stdc++.h>
using namespace std;
const int N = 500;
const long long mod = 1e9 + 7;
long long dp[N + 10][N + 10];
int b[N + 10];
long long solve(int l, int r) {
  if (l == r) {
    return 1;
  }
  if (l > r) {
    return 0;
  }
  if (dp[l][r] != -1) {
    return dp[l][r];
  }
  long long ans = 0;
  for (int i = l + 2; i <= r; i++) {
    if (b[i] > b[l + 1]) {
      ans = (ans + solve(l + 1, i - 1) * solve(i - 1, r)) % mod;
    }
  }
  ans = (ans + solve(l + 1, r)) % mod;
  return dp[l][r] = ans;
}
int main() {
  memset(dp, -1, sizeof dp);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", b + i);
  }
  printf("%lld\n", solve(1, n));
}
