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

const int MOD = 1000000007;

int count_ways_1(const vector<int> &a)
{
    vector<vector<int>> ways(a.size(), vector<int>(2, 0));
    ways[0][a[0] % 2] = 1;
    for (int i = 1; i < (int) a.size(); ++i) {
        if (a[i] % 2 == 0) {
            ways[i][0] += ways[i - 1][0];
            ways[i][0] %= MOD;
            ways[i][0] += ways[i - 1][0];
            ways[i][0] %= MOD;
            ways[i][1] += ways[i - 1][1];
            ways[i][1] %= MOD;
        } else {
            ways[i][1] += ways[i - 1][0];
            ways[i][1] %= MOD;
            ways[i][1] += ways[i - 1][0];
            ways[i][1] %= MOD;
            ways[i][0] += ways[i - 1][1];
            ways[i][0] %= MOD;
        }
    }
    return ways[a.size() - 1][0];
}

int count_ways_2(const vector<int> &a)
{
    vector<int> ways(1 + a.size(), 0);
    ways[0] = 1;
    for (int i = 1; i <= (int) a.size(); ++i) {
        int sum = 0;
        for (int j = i; j > 0; --j) {
            sum += a[j - 1];
            sum %= MOD;
            if (sum % 2 == 0) {
                ways[i] += ways[j - 1];
                ways[i] %= MOD;
            }
        }
    }
    return ways[a.size()];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    if (sum < MOD) {
        cout << count_ways_1(a) << endl;
    } else {
        cout << count_ways_2(a) << endl;
    }
    return 0;
}