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
#include<bits/stdc++.h>
using namespace std;
long long nums[300000];
bool anyGreaterThan100 = false;

long long huge_number = 1000000007;

long long solveSmallNumbers(int n)
{
    long long result;
    long long sumOdd = nums[0]%2;
    long long sumEven = (nums[0]+1)%2;
    for(int i=1;i<n;i++)
    {
        if(nums[i]%2)
        {
            if(sumOdd==0)
            {
                sumOdd=sumEven*2LL;
                sumOdd = sumOdd % huge_number;
                sumEven=0;
            }
            else
            {
                sumEven=sumOdd;
                sumOdd=0;
            }
        }
        else
        {
            sumEven = (2LL*sumEven) % huge_number;
        }
    }
    return sumEven;
}

long long solveSquare(int n)
{
    long long result;
    long long evenSums[3005];
    long long sumsModulo[3005];
    sumsModulo[0]=0LL;
    evenSums[0]=1LL;
    for(int i=1;i<=n;i++)
    {
        evenSums[i]=0LL;
        sumsModulo[i] = sumsModulo[i-1] + nums[i-1];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i;j>=0;j--)
        {
            long long sumIJ=sumsModulo[i+1]-sumsModulo[j];
            if((sumIJ % huge_number)%2==0)
                evenSums[i+1]=(evenSums[i+1] + evenSums[j]) % huge_number;
        }
        
    }
    result = evenSums[n];
    return result;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>nums[i];
        if(nums[i]>100)
            anyGreaterThan100=true;
    }
    
    if(n<3000)
        cout<<solveSquare(n);
    else if(anyGreaterThan100==false)
        cout<<solveSmallNumbers(n);
    else
        cout<<solveSquare(n);
    cout<<endl;
    return 0;
}