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
70
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

const ll MOD = 1e9 + 7;

bool mopadulo(ll x)
{
    return (x % MOD) % 2 == 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    
    vector<ll> a(n);
    ll allSum = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        allSum += a[i];
    }
    
    if (allSum < MOD)
    {
        if (allSum % 2)
        {
            cout << "0\n";
            return 0;
        }
        
        ll sum = 0, currPow = 0;
        for (int i = n - 1; i >= 0; --i)
        {
            sum += a[i];
            if (sum % 2 == 0)
            {
                if (currPow)
                    currPow *= 2;
                else
                    currPow = 1;
                currPow %= MOD;
            }
        }
        
        cout << currPow << "\n";
        return 0;
    }
    
    vector<ll> dp(n + 1, 0);
    dp[n] = 1;
    for (int i = n - 1; i >= 0; --i)
    {
        ll sum = 0;
        for (int j = i; j < n; ++j)
        {
            sum += a[j];
            dp[i] += mopadulo(sum) * dp[j + 1];
            dp[i] %= MOD;
        }
    }
    cout << dp[0] << "\n";

    return 0;
}