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
#include <iostream>

using namespace std;

const int M = 1000000007;

void fastscan(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}

int mopadulo(long long* sumy, int pocz, int kon)
{
    if(pocz == kon)
        return 0;
    if(pocz - kon == 1)
    {
        if((((sumy[kon] - sumy[pocz]) % M))% 2 == 0)
            return 1;
        return 0;
    }

    int ans = 0;

    for(int i = 1; i < kon - pocz; i++)
    {
        if(((sumy[pocz + i] - sumy[pocz]) % M) % 2 == 0)
            ans = (ans + mopadulo(sumy, pocz + i, kon) % M);
    }

    if(((sumy[kon] - sumy[pocz])&M)%2 == 0)
        ans+=1;

    return ans%M;
}

int main()
{
    int n;
    fastscan(n);

    int liczby[n];
    for(int i = 0; i < n; i++)
        fastscan(liczby[i]);

    long long sumy[n+1];
    sumy[0] = 0;
    sumy[1] = liczby[0];
    for(int i = 2; i < n+1; i++)
        sumy[i] = sumy[i-1] + (long long)liczby[i-1];

    cout << mopadulo(sumy, 0, n);
    return 0;
}