#include <bits/stdc++.h>
using namespace std;
int const M = 1e9 + 7;
int b[501], f[501][501];
inline void add(int &x, int y) {
  x += y;
  while (x < 0) x += M;
  while (x >= M) x -= M;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", b + i);
  for (int i = 0; i < n; ++i) f[i][i] = 1, f[i][i + 1] = 1;
  for (int d = 2; d < n; ++d)
    for (int i = 0; i + d < n; ++i) {
      int j = i + d;
      f[i][j] = f[i + 1][j];
      for (int k = i + 1; k < j; ++k)
        if (b[i + 1] < b[k + 1]) {
          add(f[i][j], 1ll * f[i + 1][k] * f[k][j] % M);
        }
    }
  printf("%d\n", f[0][n - 1]);
  return 0;
}
