#include <bits/stdc++.h>
int in[550], t[550][550];
const int M = 1000000007;
int dfs(int a, int b) {
  if (b - a <= 1) {
    return 1;
  }
  if (t[a][b] == -1) {
    int s = 0;
    for (int i = a + 1; i < b; i++) {
      if (in[i] > in[a]) {
        s = (s + (long long)dfs(a + 1, i) * dfs(i, b)) % M;
      }
    }
    s = (s + dfs(a + 1, b)) % M;
    t[a][b] = s;
  }
  return t[a][b];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", in + i);
  }
  memset(t, -1, sizeof(t));
  printf("%d\n", in[0] == 1 ? dfs(1, n) : 0);
  return 0;
}
