#include <bits/stdc++.h>
using namespace std;
long long dp[505][505];
int v[505];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
  for (int len = 0; len < n; ++len)
    for (int a = 0; a < n - len; ++a) {
      int b = a + len;
      if (a == b)
        dp[a][b] = 1;
      else {
        if (a == 0)
          dp[a][b] = dp[a + 1][b];
        else {
          dp[a][b] = (v[a] < v[a + 1] ? (2 * dp[a + 1][b]) % 1000000007
                                      : dp[a + 1][b]);
          for (int i = a + 1; i < b; ++i)
            if (v[a] < v[i + 1])
              dp[a][b] =
                  (dp[a][b] + (dp[a + 1][i] * dp[i + 1][b]) % 1000000007) %
                  1000000007;
        }
      }
    }
  cout << dp[0][n - 1] << "\n";
  return 0;
}
