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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")*/

#include <bits/stdc++.h>
#define bit(n, i) (((n)>>(i))&1)
#define cat(x) cout << #x << " = " << x << "\n"
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define inf 2000000000
#define llinf 2000000000000000000LL
#define forn(i, a, b) for(ll i = (a); i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
#define ppc(x) __builtin_popcount(x)
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int, int> i2;
typedef vector<int> vi;
typedef vector<ll> vll;

const int N = 3e5+9;
const int M = 1000000007;
int A[N], dp[N];

int add(int a, int b) {
    a += b;
    if(a >= M) a -= M;
    return a;
}

int mult(int a, int b) {
    return 1LL*a*b%M;
}



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    int res = 0;
    int maxa = 0;

    forn(i, 1, n) {
        cin >> A[i];
        maxa = max(maxa, A[i]);
    }

    if(n <= 3000) {
        dp[0] = 1;
        forn(i, 1, n) {
            int s = 0;
            for(int j = i; j >= 1; --j) {
                s = add(s, A[j]);
                if(!(s & 1)) {
                    dp[i] = add(dp[i], dp[j-1]);
                }
            }
        }
        res = dp[n];
    }
    else if(maxa <= 100) {

        int se = 0, so = 0;
        if(A[1] & 1) {
            so = 1;
            dp[1] = 0;
        }
        else {
            se = 1;
            dp[1] = 1;
        }
        forn(i, 2, n) {
            if(A[i] & 1) {
                swap(se, so);
                so = add(so, dp[i-1]);
            }
            else {
                se = add(se, dp[i-1]);
            }
            dp[i] = se;
        }
        res = dp[n];
    }
    else {

    }
    cout << res;


    return 0;
}