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
#include <iostream> 
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;

const int MAXN = 300010;
const ll P = 1000000007;
ll sp[MAXN] = {0};
vector<ll> k[MAXN];
ll wn[MAXN] = {0};
vector<pair<ll,ll>> vp;

inline bool check(int p, int k) {
    return !(((sp[k] - sp[p]) % P) & 1);
}

int main() {
    ios::sync_with_stdio(false);    
    int n;
    ll x = 0, csp = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        csp += x;
        sp[i] = csp;
    }

    for (int i = 0; i < n; i++) {
        for(int j = i+1; j <= n; j++) {
            if (check(i, j)) {
                vp.push_back(make_pair(i, j));
            }
        }
    }

    for(int i = 0; i < vp.size(); i++) {
        k[vp[i].second].push_back(vp[i].first);
    }

    wn[0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < k[i].size(); j++) {
            wn[i] += wn[k[i][j]];
            wn[i] %= P;
        }
    }
    
    cout << wn[n] << endl;
}