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
#include <iostream>     // std::cout
#include <algorithm>    // std::sort
#include <vector>       // std::vector
#include <set>
#include <cmath>
#include <string>
#include <map>
#include <cassert>
#include <functional>
#include <tuple>

using namespace std;

#define MOD 1000000007
#define MAXN 300010
#define DEBUG 0

int n, a[MAXN];
long long sum[MAXN], res[MAXN];
vector<int> v[MAXN];

bool is_mopadulo(long long number){
    return ((number % MOD) & 1) == 0;
}

long long dfs(int interval_start){
    // entered from interval that was ending at n - vertex
    if (interval_start > n){
        return 1;
    }
    if (res[interval_start] >= 0){
        return res[interval_start];
    }
    res[interval_start] = 0;
    for (int interval_end : v[interval_start]){
        res[interval_start] = (res[interval_start] + dfs(interval_end + 1)) % MOD;
    }
    return res[interval_start];
}

int main() {
    scanf("%d", &n);
    for(int i=1; i<=n; ++i){
        scanf("%d", &a[i]);
        sum[i] = (sum[i-1] + a[i]) % MOD;
        res[i] = -1;
    }
    
    for (int i=1; i<=n; ++i){
        for (int j=i; j<=n; ++j){
            if (is_mopadulo(sum[j] - sum[i-1] + MOD)) {
                v[i].push_back(j);
            }
        }
    }
    printf("%lld", dfs(1));
    return 0;
}