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
97
98
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

long long MOD = 1000000007;

bool is_small(vector<long long>& v) {
    int n = v.size();
    long long acc = 0;
    for (int i = 0; i < n; i++) {
        acc += v[i];
        if (acc >= MOD) {
            return false;
        }
    }
    return true;
}

long long big(vector<long long>& v) {
    int n = v.size();
    vector<long long> res;
    for (int i = 0; i < n; i++) {
        long long acc = 0, total = 0, prv;
        for (int j = i; j >= 0; j--) {
            acc += v[j];
            if (j > 0) {
                prv = res[j - 1];
            }
            else {
                prv = 1;
            }
            if ((acc % MOD) % 2 == 0) {
                total += prv;
                total %= MOD;
            }
        }
        res.push_back(total);
    }
    return res[n - 1];
}

long long small(vector<long long>& v) {
    int len = v.size();
    vector<long long> p;
    vector<long long> n;
    vector<long long> r;
    for (int i = 0; i < len; i++) {
        if (i == 0) {
            if (v[i] % 2 == 0) {
                p.push_back(1);
                n.push_back(0);
                r.push_back(0);
            }
            else {
                p.push_back(0);
                n.push_back(1);
                r.push_back(0);
            }
        }
        else {
            if (v[i] % 2 == 0) {
                p.push_back((p[i - 1] + p[i - 1]) % MOD);
                n.push_back(n[i -1 ]);
                r.push_back((r[i - 1] + r[i - 1] + n[i - 1]) % MOD);
            }
            else {
                p.push_back(n[i - 1]);
                n.push_back((p[i - 1] + p[i - 1]) % MOD);
                r.push_back((r[i - 1] + r[i - 1] + n[i - 1]) % MOD);
            }
        }
    }
    return p[len - 1];
}

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

    int n;
    cin >> n;
    vector<long long> v;
    for (int i = 0; i < n; i++) {
        long long e;
        cin >> e;
        v.push_back(e);
    }
    if (is_small(v)) {
         cout << small(v);
    }
    else {
        cout << big(v);
    }

    return 0;
}