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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;

#define st first
#define nd second

typedef pair<int,int> pun;
typedef long long ll;

ll mod = 1000 * 1000 * 1000 + 7;

void n2(vector<int> v, vector<ll> pref) {
	vector<ll> dp;
	dp.resize(v.size());
	dp[0] = 1;
	for (int i = 1; i < pref.size(); i ++) {
		for (int j = 0; j < i; j ++) {
			if (((pref[i] - pref[j]) % mod) % 2 == 0) {
				dp[i] += dp[j];
			}
		}
		dp[i] %= mod;
	}
	cout << dp[v.size() - 1];
}

void heura(vector<int> v, vector<ll> pref) {
	vector<ll> dp;
	dp.resize(v.size());
	dp[0] = 1;
	ll p = 1;
	ll np = 0;
	for (int i = 1; i < pref.size(); i ++) {
		if (pref[i] % 2) {
			dp[i] = np;
			np += dp[i];
			np %= mod;
		} else {
			dp[i] = p;
			p += dp[i];
			p %= mod;
		}
	}
	cout << dp[v.size() - 1];
}

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> v;
	v.push_back(0);
	for (int i = 0; i < n; i ++) {
		int x;
		cin >> x;
		v.push_back(x);
	}
	vector<ll> pref;
	pref.push_back(0);
	for (int i = 1; i <= n; i ++) {
		pref.push_back(pref.back() + v[i]);
	}
	if (pref.back() < mod) {
		heura(v, pref);
	}
	else n2(v, pref);
}