#include <bits/stdc++.h>
const int N = 505;
const int mod = 1e9 + 7;
void add(int &x, int val) {
  x += val;
  if (x >= mod) x -= mod;
}
int a[N], e[N][N], d[N][N];
void Go(int n) {
  for (int r = 0; r < n; r++)
    for (int l = r; ~l; l--) {
      if (l == r) {
        e[l][r] = d[l][r] = 1;
      } else {
        e[l][r] = d[l + 1][r];
        d[l][r] = e[l][r];
        for (int pos = l + 1; pos <= r; pos++) {
          if (a[l] < a[pos]) {
            add(d[l][r], e[l][pos - 1] * (long long)d[pos][r] % mod);
          }
        }
      }
    }
  printf("%d\n", e[0][n - 1]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  Go(n);
  return 0;
}
