#include <bits/stdc++.h>
const int mo = 1e9 + 7;
using namespace std;
int n, i, j, k, l, a[501];
long long f[501][501];
int main() {
  scanf("%d\n", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    f[i][i] = 1;
  }
  for (l = 2; l <= n; l++)
    for (i = 1; i <= n - l + 1; i++) {
      j = i + l - 1;
      for (k = i + 1; k <= j; k++)
        if (k == j || a[i + 1] < a[k + 1])
          f[i][j] = (f[i][j] + f[i + 1][k] * f[k][j]) % mo;
    }
  printf("%I64d", f[1][n]);
}
