#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
int n, v[500], fg[500], dp[500][500];
vector<vector<int> > g;
int calc(int i, int j) {
  if (i == j) return 1;
  if (i > j) return 1;
  int &ret = dp[i][j];
  if (ret != -1) return ret;
  ret = calc(i + 1, j);
  for (int z = 0; z < g[i].size(); ++z) {
    int k = g[i][z];
    if (g[i][z] <= j)
      ret = (ret + (long long)calc(i + 1, k - 1) * calc(k, j)) % M;
    else
      break;
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  g.resize(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", v + i);
    --v[i];
  }
  for (int i = 0; i < n; ++i) {
    fg[i] = n;
    for (int j = i + 1; j < n; ++j)
      if (v[i] < v[j]) {
        g[i].push_back(j);
      }
  }
  memset(dp, -1, sizeof(dp));
  printf("%d\n", (calc(1, n - 1)) % M);
  return 0;
}
