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