#include <bits/stdc++.h>
using namespace std;
const int maxn = 507;
int a[maxn], n;
long long f[maxn][maxn], f2[maxn][maxn];
long long dp(int i, int j);
long long dp2(int i, int j);
long long dp2(int i, int j) {
  if (f2[i][j] != -1) return f2[i][j];
  long long &res = f2[i][j];
  if (i == j) return (res = 1);
  res = dp(i, j);
  for (int x = i + 1; x <= j; ++x)
    if (a[i] < a[x]) res = (res + dp(i, x - 1) * dp2(x, j)) % 1000000007;
  return res;
}
long long dp(int i, int j) {
  if (f[i][j] != -1) return f[i][j];
  long long &res = f[i][j];
  res = 0;
  if (i == j) return (res = 1);
  return (res = dp2(i + 1, j));
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  memset(f, -1, sizeof(f));
  memset(f2, -1, sizeof(f2));
  cout << dp(1, n) << endl;
}
