#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n;
int a[501];
int f[501][501] = {};
inline int add(int x, int y) {
  x += y;
  return x < mod ? x : x - mod;
}
inline int mul(int x, int y) { return 1ll * x * y % mod; }
int dp(int i, int j) {
  if (f[i][j]) return f[i][j];
  for (int k = i + 1; k <= j; ++k)
    if (a[i + 1] < a[k + 1] || k == j)
      f[i][j] = add(f[i][j], mul(dp(i + 1, k), dp(k, j)));
  return f[i][j];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), f[i][i] = 1;
  cout << dp(1, n);
  return 0;
}
