#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const int mod = (int)1e9 + 7;
int dp1[N][N], dp2[N][N], a[N];
int go2(int st, int en);
int go1(int st, int en) {
  if (st == en) {
    return 1;
  }
  int& ret = dp1[st][en];
  if (~ret) return ret;
  ret = go2(st + 1, en);
  return ret;
}
int go2(int st, int en) {
  if (st == en) {
    return 1;
  }
  int& ret = dp2[st][en];
  if (~ret) return ret;
  ret = go1(st, en);
  for (int i = st + 1; i <= en; ++i) {
    if (a[st] < a[i]) {
      ret += (long long)go1(st, i - 1) * go2(i, en) % mod;
      if (ret >= mod) ret -= mod;
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  memset(dp1, -1, sizeof(dp1));
  memset(dp2, -1, sizeof(dp2));
  cout << go1(0, n - 1) << '\n';
  return 0;
}
