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
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

ll dp[3][3];

int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<ll> a(n + 1);
	ll sum = 0;
	REP(i, n) {
	    cin >> a[i];
	    sum += a[i];
	}
	if (sum % 2 == 1) {
	    cout << 0 << endl;
	    return 0;
	}
	sum = 0;
	REP(i, n) {
	    sum += a[i];
	    int fst = (sum / MOD) % 2;
	    int snd = (sum % MOD) % 2;
	    if ((fst + snd) % 2 == 0) {
	        dp[fst][snd] = ((snd == 0) + dp[0][0] + dp[1][1]) % MOD;
	    } else {
	        dp[fst][snd] = ((snd == 0) + dp[0][1] + dp[1][0]) % MOD;
	    }
	   // cout << dp[0][0] << " " << dp[0][1] << " " << dp[1][0] << " " << dp[1][1] << endl;
	}
    int fst = (sum / MOD) % 2;
    int snd = (sum % MOD) % 2;
    cout << dp[fst][snd] << endl;
	return 0;
}