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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
int n;
ll a[300001];
ll dp[300001];

void brut()
{
    dp[0]=1;
    for(int i=1; i<=n; ++i)
    {
        int s = 0;
        for(int j=i-1; j>=0; --j)
        {
            s += a[j];
            s %= mod;
            //printf("%d ", s);
            if(s % 2 == 0)
                dp[i] += dp[j];
            dp[i] %= mod;
        }
        //printf("%d\n", dp[i]);
    }
    printf("%lld\n", dp[n]);
}

void mal()
{
    ll sp[2] = {1, 0};
    ll ob_dp = 0;
    int it = 0;
    for(int i=0; i^n; ++i)
    {
        ob_dp = 0;
        if(a[i] % 2 == 1)
        {
            it ^= 1;
            if(it == 0)
            {
                ob_dp = sp[it];
                sp[it] += ob_dp;
                sp[it] %= mod;
            }
        }
        else
        {
            if(it == 0)
            {
                ob_dp = sp[it];
                sp[it] += ob_dp;
                sp[it] %= mod;
            }
        }
    }
    printf("%lld\n", ob_dp);
}

int main()
{
    scanf("%d", &n);
    for(int i=0; i^n; ++i)
    {
        scanf("%lld", &a[i]);
    }
    if(n <= 3000)
    {
        brut();
    }
    else
    {
        mal();
    }
}