#include <bits/stdc++.h>
using namespace std;
const int N = 500 + 5, mod = 1e9 + 7;
int st[N][N], md[N][N], a[N], n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) st[i][i + 1] = md[i][i + 1] = 1;
  for (int ln = 2; ln <= n; ln++) {
    for (int i = 0; i + ln <= n; i++) {
      int j = i + ln;
      st[i][j] = md[i][j] = md[i + 1][j];
      for (int fr = i + 1; fr < j; fr++)
        md[i][j] =
            (md[i][j] + 1ll * st[i][fr] * md[fr][j] * (a[i] < a[fr]) % mod) %
            mod;
    }
  }
  cout << st[0][n];
}
