1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  constexpr int p = 1e9 + 7;
  int n; cin >> n;
  vector<int> dp(n+1), pref(n+1);

  for (int i = 1; i <= n; ++i) {
    cin >> pref[i];
    pref[i] = (pref[i] + pref[i-1]) % p;
  }

  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = i-1; j >= 0; --j) {
      bool pred = not (((pref[i] - pref[j] + p) % p) % 2);
      dp[i] = (dp[i] + dp[j]*pred) % p;
    }
  }

  cout << dp[n];
}