#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
const long long base = 1000000007;
int a[501], n;
long long g[501][501];
bool done[501][501];
long long G(int i, int j) {
  if (i > j) return 1;
  if (done[i][j]) return g[i][j];
  done[i][j] = 1;
  g[i][j] = G(i + 1, j);
  for (int k = i + 1; k <= j; k++)
    if (a[i] < a[k]) g[i][j] = (g[i][j] + G(i + 1, k - 1) * G(k, j)) % base;
  return g[i][j];
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  writeln(G(2, n));
}
