#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 500 + 5;
const int mod = 1e9 + 7;
int n, a[N], dp[N][N];
int f(int x, int y) {
  if (x >= y) return 1;
  int &r = dp[x][y];
  if (r != -1) return r;
  r = f(x + 1, y);
  for (int i = x + 1; i <= y; i++)
    if (a[x] < a[i]) r = (r + (long long)f(x + 1, i - 1) * f(i, y)) % mod;
  return r;
}
int main() {
  ios ::sync_with_stdio(0);
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cout << f(2, n) << '\n';
  return 0;
}
