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
#include <cstdio>
#include <vector>
using namespace std;

#define FOR(i,a,b) for(int (i)=(int)(a); (i)!=(int)(b); ++(i))
#define MOD 1000000007

typedef unsigned long long int ulli;

int solve_small(vector<int> &A) {
    int P=1, N=0;
    if (A[0]%2) swap(P, N);
    FOR(i,1,A.size()) {
        P = (P << 1) % MOD;
        if (A[i]%2) swap(P, N);
    }
    return P;
}

int solve_n2(vector<int> &A) {
    vector<int> T(A.size()+1, 0);
    T[0] = 1;
    FOR(i,0,A.size()) {
        int S = 0;
        FOR(j,0,i+1) {
            S = (S + A[i-j]) % MOD;
            if (S&1) continue;
            T[i+1] = (T[i+1] + T[i-j]) % MOD;
        }
    }
    return T[A.size()];
}

int solve(vector<int> &A) {
    ulli sum = 0;
    FOR(i,0,A.size()) sum += A[i];
    if (sum < MOD) return solve_small(A);
    return solve_n2(A);
}

int n;
vector<int> A;
int main() {
    scanf("%d", &n); A.resize(n);
    FOR(i,0,n) scanf("%d", &A[i]);
    int result = solve(A);
    printf("%d\n", result);
}