#include <bits/stdc++.h>
using namespace std;
const long long logN = 20;
const long long N = 100005;
const long long M = 1000000007;
const long long INF = 1e12;
long long pow1(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % M;
    }
    a = (a * a) % M;
    b >>= 1;
  }
  return res % M;
}
vector<long long> a(N);
long long n;
long long dp[505][505];
long long d[505][505];
long long calc(long long i, long long j) {
  if (i >= j) return 1;
  if (d[i][j]) return dp[i][j];
  d[i][j] = 1;
  dp[i][j] = calc(i + 1, j);
  dp[i][j] %= M;
  for (long long k = i + 1; k <= j; k++) {
    if (a[i] < a[k]) {
      dp[i][j] += (calc(i + 1, k - 1) * calc(k, j));
      dp[i][j] %= M;
    }
  }
  return dp[i][j];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T = 1;
  while (T--) {
    cin >> n;
    for (long long i = 1; i < n + 1; i++) cin >> a[i];
    if (n == 1) {
      cout << "1"
           << "\n";
      return 0;
    }
    cout << calc(2, n);
  }
}
