#include <bits/stdc++.h>
using namespace std;
void add(int &x, int y) { x = x + y < 1000000007 ? x + y : x + y - 1000000007; }
int dp[500 + 5][500 + 5];
int a[500 + 5];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) dp[i][i] = 1;
  for (int L = 2; L <= n; L++)
    for (int l = 1; l <= n - L + 1; l++) {
      int r = l + L - 1;
      dp[l][r] = dp[l + 1][r];
      for (int i = l + 2; i <= r; i++)
        if (a[l + 1] < a[i])
          add(dp[l][r], 1ll * dp[l + 1][i - 1] * dp[i - 1][r] % 1000000007);
    }
  printf("%d\n", dp[1][n]);
  return 0;
}
