#include <bits/stdc++.h>
using namespace std;
int N;
int A[520];
long long D[520][520];
int K[520][520];
long long MOD(long long x) { return x % 1000000007; }
void read() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
}
long long f(int a, int b) {
  if (K[a][b]) return D[a][b];
  K[a][b] = 1;
  if (a >= b) return D[a][b] = 1;
  long long result = 0;
  for (int i = a + 1; i <= b; i++)
    if (A[a] < A[i]) {
      result += MOD(f(a + 1, i - 1) * f(i, b));
      result = MOD(result);
    }
  result += f(a + 1, b);
  return D[a][b] = MOD(result);
}
int main() {
  read();
  cout << ((N == 1) ? 1 : f(1, N - 1)) << endl;
  return 0;
}
