#include <bits/stdc++.h>
using namespace std;
const int N = 510, mod = 1LL * 1000 * 1000 * 1000 + 7;
int dp[N][N], n, b[N], num[N][N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int j = 1; j <= n; j++)
    for (int i = j - 1; i >= 0; i--) {
      if (j - i <= 2) {
        dp[i][j] = num[i][j] = 1;
        continue;
      }
      for (int k = i + 1; k + 1 < j; k++)
        if (b[k] < b[j - 1])
          (num[i][j] += 1LL * num[i][k + 1] * dp[k][j - 1] % mod) %= mod;
      for (int k = i + 1; k < j; k++)
        (dp[i][j] += 1LL * num[i][k + 1] * dp[k][j] % mod) %= mod;
    }
  cout << dp[0][n] << '\n';
  return 0;
}
