#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long dp[510][510], dp2[510][510];
int a[510];
void add(long long &x, long long v) { x = (x + v) % MOD; }
int main() {
  int(n);
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) scanf("%d", &(a[i]));
  for (int i = 0; i < (n); ++i) dp[i][i] = dp2[i][i] = 1;
  for (int i = (1); i < (n); ++i) {
    for (int j = 0; j + i < n; j++) {
      int ll = j;
      int rr = j + i;
      dp[ll][rr] = dp2[ll + 1][rr];
      for (int k = (ll); k < (rr); ++k) {
        if (a[ll] < a[k + 1]) add(dp2[ll][rr], dp[ll][k] * dp2[k + 1][rr]);
      }
      add(dp2[ll][rr], dp[ll][rr]);
    }
  }
  cout << dp[0][n - 1] << endl;
  return 0;
}
