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
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll f1 (int n, vector <int>& v, ll mod) {
	vector <ll> pref(n+1);
	for (int i = 0; i < n; i++) {
		pref[i+1] = pref[i] + (ll)v[i];
		pref[i+1] %= mod;
	}
	vector <ll> dp(n+1);
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = i-1; j >= 0; j--) {
			if ((((pref[i] - pref[j] + mod) % mod) % 2) == 0) {
				dp[i] += dp[j];
				dp[i] %= mod;
			}
		}
	}
	return dp[n];
	//cout << dp[n] << "\n";
}

ll f2 (int n, vector <int>& v, ll mod) {
	vector <ll> dp(n+1);
	int lastn = -1;
	for (int i = 1; i <= n; i++) {
		if (v[i-1] % 2 == 0) {
			dp[i] = dp[i-1] * 2;
			if (i - 1 == 0)
				dp[i]++;
		}
		else {
			if (lastn != -1)
				dp[i] = dp[lastn] * 2;
			if (lastn == 0)
				dp[i]++;
			lastn = i - 1;
		}
		dp[i] %= mod;
	}
	return dp[n];
	//cout << dp[n] << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	ll mod = 1000000007;
	vector <int> v(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		sum += v[i];
	}
	if (sum < mod)
		cout << f2(n, v, mod) << "\n";
	else 
		cout << f1(n, v, mod) << "\n";
	return 0;
}