#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const int MOD = 1000000007;
long long f[N][N];
int b[N];
bool vis[N][N];
int n;
long long dfs(int l, int r) {
  if (vis[l][r]) return f[l][r];
  vis[l][r] = 1;
  if (r - l <= 1) return f[l][r] = 1;
  long long ans = 0;
  for (int i = l + 1; i <= r; i++) {
    if (i == r || b[i + 1] > b[l + 1]) {
      ans += dfs(l + 1, i) * dfs(i, r);
      ans %= MOD;
    }
  }
  return f[l][r] = ans;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> b[i];
  if (b[1] != 1) {
    cout << 0 << endl;
    return 0;
  }
  cout << dfs(1, n) << endl;
}
