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
70
71
72
73
74
75
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define st first
#define nd second
#define bg begin
#define ed end
#define pb push_back
#define all(r) bg(r),ed(r)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) 

int mod=1e9+7;
int bipow(int a,int b){
	int res=1;
	while(b>0){
		if(b%2==1){
			res=res*a%mod;
		}
		a=a*a%mod;
		b/=2;
	}
	return res;
}

void solve1(vector<int>&v){
	int sum=0;
	int res=0;
	for(int i=0;i<(int)v.size();i++){
		sum+=v[i]%2;
		if(sum%2==0){
			res++;
		}
	}
	if(sum%2==1){
		cout<<0<<'\n';
	}else{
		cout<<bipow(2,res-1)<<'\n';
	}
}

void solve2(vector<int>&v,int n){
	vector<int>res(n+1);
	res[0]=1;
	for(int i=1;i<n+1;i++){
		int sum=0;
		int r=0;
		for(int j=1;j<=i;j++){
			sum=(sum+v[i-j])%mod;
			if(sum%2==0){
				r=(r+res[i-j])%mod;
			}
		}
		res[i]=r;
	}
	cout<<res[n]<<'\n';
}

int32_t main(){
	fast;
	int n;
	cin>>n;
	vector<int> v(n);
	int ma=0;
	for(auto& x:v){
		cin>>x;
		ma=max(ma,x);
	}
	if(n<3000){
		solve2(v,n);
	}else{
		solve1(v);
	}
	
}