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

const int P = 1000000000 + 7;

int main() {
    std::ios::sync_with_stdio(false);
    int n, total_sum = 0;
    cin >> n;
    vector<int> sums = {0}, splits = {1};
    for(int i = 1; i < n + 1; ++i) {
        int x, cur_splits = 0;
        cin >> x;
        total_sum = (total_sum + x) % P;
        sums.push_back(total_sum);

        for(int j = 0; j < i; ++j) {
            if(((P + sums[i] - sums[j]) % P) % 2 == 0) {
                cur_splits = (cur_splits + splits[j]) % P;
            }
        }
        splits.push_back(cur_splits);
    }
    cout << splits.back() << endl;
}