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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MAKS = 5*1e5 + 2;
const int MOD = 1e9+7;
ll tab[MAKS];
ll ans[MAKS];
void brut1(int n)
{
    ll sum = 0;
    for(int i = 0; i < n ; i++)
    {
        sum += tab[i];
        sum %= MOD;
        if(sum%2 == 0)
        {
            ans[i+1] = 1;
        }
    }
    for(int i = 1; i < n; i++)
    {
        sum = 0;
        for(int j = i; j < n ; j++)
        {
            sum += tab[j];
            sum %= MOD;
            if(sum%2 == 0)
            {
                ans[j+1] += ans[i];
                ans[j+1] %= MOD;
            }
        }
    }
    cout << ans[n] % MOD << "\n";
}
void brut2(int n)
{

    int ile_np = 0;
    for(int i = 0 ; i < n ; i++)
    {
        ile_np += tab[i]%2;
    }
    if(ile_np % 2 == 1)
    {
        cout << "0\n";
        return ;
    }

    ll wyn = 1;

    bool firstOne = 0;

    for(int i = 0 ; i < n; i++)
    {
        if(tab[i]%2 == 1 && firstOne == 0)
        {
            firstOne = 1;
        } else if(tab[i] % 2 == 1 && firstOne == 1)
        {
            firstOne = 0;

            wyn *= 2;
            wyn %= MOD;

        } else if(tab[i] % 2 == 0 && firstOne == 0)
        {
            wyn *= 2;
            wyn %= MOD;
        }
    }
    cout << wyn % MOD << "\n";
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


    int n; cin >> n;
    ll maks = 0;
    for(int i = 0; i < n ; i++)
    {
        cin >> tab[i];
        maks = max(maks,tab[i]);
    }
    if(n <= 3000)
    {
        brut1(n);
    } else if (maks <= 100)
    {
        brut2(n);
    } else
    {
        brut1(n);
    }


}