#include <bits/stdc++.h>
using namespace std;
long long memo[510][510];
long long arr[510];
long long answer(int l, int r) {
  if (memo[l][r] != -1) {
    return memo[l][r];
  }
  if (l == r) {
    memo[l][r] = 1;
    return 1;
  }
  long long ans = 0;
  for (int i = l + 1; i <= r; i++) {
    if (i == r || arr[i + 1] > arr[l + 1]) {
      ans = (ans % 1000000007 + (answer(l + 1, i) * answer(i, r))) % 1000000007;
    }
  }
  memo[l][r] = ans;
  return ans;
}
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  memset(memo, -1, sizeof(memo));
  cout << answer(0, n - 1) << endl;
  return 0;
}
