#include <bits/stdc++.h>
using namespace std;
const int size = 502;
long long n, b[size], dp[size][size];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> b[i], dp[i][i] = dp[i + 1][i] = 1;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int k = 2; k <= n; k++)
    for (int i = 1; i + k - 1 <= n; i++) {
      int j = i + k - 1;
      dp[i][j] = dp[i + 1][j];
      for (int z = i + 1; z <= j; z++)
        if (b[i] < b[z])
          dp[i][j] = (dp[i][j] + dp[i + 1][z - 1] * dp[z][j]) % 1000000007;
    }
  int i, j;
  cout << dp[2][n] << endl;
}
