#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
const int MAXN = 517;
int n, arr[MAXN];
long long dp[MAXN][MAXN], adp[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  for (int i = 0; i < n; i++) dp[i][i] = 1;
  for (int j = 0; j < n; j++) {
    adp[j + 1] = 1;
    for (int i = j; i >= 0; i--) {
      adp[i] = 0;
      for (int k = i + 1; k <= j + 1; k++)
        if (k == j + 1 || arr[i] < arr[k])
          adp[i] = (adp[i] + adp[k] * dp[i][k - 1]) % (1000000007);
      if (i > 0) dp[i - 1][j] = adp[i];
    }
  }
  printf(
      "%lld"
      "\n",
      dp[0][n - 1]);
  return 0;
}
