#include <bits/stdc++.h>
using namespace std;
long long dp[600][600];
int N;
int A[600];
long long rec(int l, int r) {
  if (dp[l][r] != -1) {
    return dp[l][r];
  }
  if (l == r) {
    return dp[l][r] = 1;
  }
  if (l == r + 1) {
    return dp[l][r] = 1;
  }
  dp[l][r] = 0;
  for (int first = (l + 1); first < (r + 2); ++first) {
    if (first != r + 1 && A[l] > A[first]) {
      continue;
    }
    dp[l][r] =
        (((dp[l][r]) +
          ((((rec(l + 1, first - 1)) * (rec(first, r))) % (1000000007)))) %
         1000000007);
  }
  return dp[l][r];
}
int main(int argc, char **argv) {
  memset(dp, -1, sizeof(dp));
  cin >> N;
  for (int i = (0); i < (N); ++i) {
    cin >> A[i];
  }
  cout << rec(1, N - 1);
  return 0;
}
