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
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include<algorithm>
#include<vector>

using namespace std;

#define P 1000000007



int main()
{

    std::ios_base::sync_with_stdio(false);
    long long int i, n;
    long long int tab[300100];
    long long int presum[300100] = { 0 };
    long long int ways[300100] = { 0 };

    vector<int> even, odd;

    ways[0] = 1;
    presum[0] = 0;

    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> tab[i];
        presum[i] = presum[i - 1] + tab[i];
    }

    long long ans = 0;

    if (presum[n] < P) {
        if (presum[n] % 2 == 1) {
            cout << '0' << '\n';
            return 0;
        }
        for (int kon = 1; kon <= n; kon++) {
            if (presum[kon] % 2 == 0) {
                if (ans == 0) {
                    ans = 1;
                }
                else
                {
                    ans = (ans*2) % P;
                }
            }
        }
        cout << ans << '\n';
        return 0;
    }
    else
    {
        for (int kon = 1; kon <= n; kon++) {
            for (int pocz = 0; pocz < kon; pocz++) {
                if (((presum[kon] - presum[pocz]) % P) % 2 == 0) {
                    ways[kon] = (ways[kon] + ways[pocz]) % P;
                    //cout << "adding " << pocz << " to " << kon << '\n';
                }
            }
            //cout << ways[kon] << '\n';
        }
        cout << ways[n] << '\n';
        return 0;
    }
    return 0;
}