#include <bits/stdc++.h>
using namespace std;
int getint() {
  int _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
bool equal(double _x, double _y) { return _x > _y - 1e-7 && _x < _y + 1e-7; }
int __ = 1, cs;
int n, a[510], dp[510][510];
void build() {}
void init() {
  n = getint();
  for (int i = 1; i <= n; i++) a[i] = getint();
}
int DP(int l, int r) {
  if (l > r) return 1;
  if (dp[l][r]) return dp[l][r];
  if (l == r) return dp[l][r] = 1;
  int sum = DP(l + 1, r);
  for (int i = l + 1; i <= r; i++)
    if (a[i] > a[l]) {
      long long tsum = ((long long)(DP(l + 1, i - 1)) * (long long)(DP(i, r))) %
                       1000000007ll;
      sum = (sum + (int)tsum) % 1000000007ll;
    }
  return dp[l][r] = sum;
}
void solve() {
  if (n == 1)
    puts("1");
  else
    printf("%d\n", DP(2, n));
}
int main() {
  build();
  while (__--) {
    init();
    solve();
  }
}
