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
// Krzysztof Baranski (2021.12.08)
#include <cstdio>
#include <unordered_map>
using namespace std;

const static unsigned MOD = 1000000007;

int n;
unsigned sequence[300002];
int cache[300002];

inline unsigned add_mopadulo(unsigned x, unsigned y) {
    return (x + y) % MOD;
}
inline unsigned is_mopadulo(unsigned x) {
    return x % 2 == 0;
}

unsigned count_mopadulo(int from) {
    if(n - from == 1) return is_mopadulo(sequence[from]);
    if(cache[from] != -1) return cache[from];

    unsigned sum = 0;
    unsigned counter = 0;
    for(int i=from; i<n; ++i) {
        sum = add_mopadulo(sum, sequence[i]);
        if(is_mopadulo(sum)) {
            if(n - i == 1) counter = add_mopadulo(counter, 1);
            else counter = add_mopadulo(counter, count_mopadulo(i+1));
        }
    }

    return cache[from] = counter;
}

int main() {
    scanf("%d\n", &n);
    for(int i=0; i<n; scanf("%u", sequence + i++)) cache[i] = -1;

    printf("%u\n", count_mopadulo(0));
    return 0;
}