// Overflow で WA になるはず #include #include using namespace std; constexpr unsigned md = 1000000007; int main() { int N; cin >> N; vector dp(3); // 0: even-dominant, 1: equal, 2: odd-dominant (1 は不要だが…) dp[0] = 1; while (N--) { int p; cin >> p; vector nxtdp = dp; if (p < 50) { nxtdp[0] += dp[0]; nxtdp[1] += dp[1]; nxtdp[2] += dp[2]; } else if (p == 50) { nxtdp[1] += dp[0] + dp[1] + dp[2]; } else { nxtdp[0] += dp[2]; nxtdp[1] += dp[1]; nxtdp[2] += dp[0]; } dp = nxtdp; } cout << dp[2] % md << '\n'; }