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

using namespace std;

int mopd=1000000007;

int a[300001];

int s[300001];


int main() {
    int n;
    scanf("%d",&n); bool small=true;
    for(int i=0; i < n; ++i) {
        scanf("%d",a+i);
        if(a[i] > 300) small=false;
    }

    if(small) {
        int parsum, nparsum;
        if(a[0] % 2==0) { s[0]=1; parsum=1; nparsum=0; }
        else { s[0]=0; nparsum=1; parsum=0; }

        for(int j=1; j<n; ++j) {
            //wylicz s[j]:
            if(a[j]%2==0) {
                parsum+=s[j-1];
                parsum%=mopd;
                s[j]=parsum;

            }
            else {
                s[j]=nparsum;
                swap(parsum,nparsum);
                nparsum+=s[j-1];
                nparsum%=mopd;
            }
        }

        printf("%d\n",s[n-1]);
        return 0;
    }

    if(a[0]%2==0) s[0]=1;
    else s[0]=0;
    for(int j=1; j<n; ++j) {
        int sum=a[j]; s[j]=0;
        for(int count=1; count <= j; count++) {
            if(sum % 2 == 0) {
                s[j]+=s[j-count];
                s[j]%=mopd;
            }
            sum+=a[j-count];
            sum%=mopd;
        }
        if(sum%2==0) { s[j]+=1; s[j]%=mopd; }

    }
    printf("%d\n",s[n-1]);

    return 0;
}