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
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
int n;
LL t[300009];
LL dp[300009][2];

void f1(){
	LL sum = 0;
	for(int i=1; i<=n; i++){
		sum+=t[i];
		if(sum%2==0){
			if(t[i]%2==0){
				dp[i][0]=max(1LL, (dp[i-1][0]*2)%MOD);
			}else{
				dp[i][0]=max(1LL, (dp[i-1][1]*2)%MOD);
			}
		}else{
			if(t[i]%2!=0){
				dp[i][1]=(dp[i-1][0])%MOD;
			}else{
				dp[i][1]=(dp[i-1][1])%MOD;
			}
		}
	}
}

void f2(){
	dp[0][0]=1;
	LL sum = 0;
	for(int i=1; i<=n; i++){
		sum+=t[i];
		LL res = 0;
		LL sum2 = 0;
		for(int j=i; j>0; j--){
			sum2+=t[j];
			if((sum2%MOD)%2==0){
				res= (res+dp[j-1][0])%MOD;
			}
		}
		dp[i][0]=res%MOD;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin>>n;
	LL SUMA=0;
	for(int i=1; i<=n; i++){
		cin>>t[i];
		SUMA+=t[i];
	}
	if(SUMA < MOD){
		f1();
	}else{
		f2();
	}
	cout<<dp[n][0]<<"\n";
	return 0;
}