#include <bits/stdc++.h>
using namespace std;
long long gg[511][511], g[511][511], f[511][511], ff[511][511], a[511], n;
const int base = 1000000007;
int go(int, int);
int go2(int, int);
int go2(int l, int r) {
  if (gg[l][r] == 1) return ff[l][r];
  if (l > r) return 1;
  gg[l][r] = 1;
  for (int i = l; i <= r; i++)
    if (i + 1 > r || a[i + 1] > a[l])
      ff[l][r] = (ff[l][r] + 1ll * go(l, i) * go2(i + 1, r) % base) % base;
  return ff[l][r];
}
int go(int l, int r) {
  if (g[l][r] == 1) return f[l][r];
  g[l][r] = 1;
  return f[l][r] = go2(l + 1, r);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cout << go(1, n) << "\n";
  return 0;
}
