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

using namespace std;

const long long MOD = 1000000007;
const int MAX_N = 3000;
int n;
long long a[MAX_N];
long long dp[MAX_N];

void solve() {
    
    cin>>n;
    long long max_a = 0;
    for(int i = 0; i<n; i++){
        cin>>a[i];
        max_a = max(max_a,a[i]);
    }
    // rozwiazanie 1
   if(max_a<=3000) {
        long long sp = 0;
        long long sn = 0;
        int h =1;
        for(int i = 0;i<n;i++) {
            if(a[i]%2==h){
                dp[i]=sn;
                dp[i]%=MOD;
                sn+=dp[i];
                sn%=MOD;
                if(a[i]%2)
                h=(h+1)%2;
            } else {
                dp[i]=sp+1;
                dp[i]%=MOD;
                sp+=dp[i];
                sp%=MOD;
                h = 1;
            }
        }
      /*  for(int i = 0; i<n; i++){
            cout<<i<<": "<<dp[i]<<"\n";
        }*/
        //cout<<"\n\n";
        
       cout<<dp[n-1]<<"\n";
       return;
    }
    for(int i =0;i<n;i++) 
        dp[i]=0;

    for(int i =0;i<n;i++) {
        long long s = a[i];
        for(int j = i-1; j>=0;j--) {
            if((s%MOD)%2==0)
                dp[i]+=dp[j];
            s+=a[j];
        }
        if((s%MOD)%2==0)
            dp[i]+=1;
    }
   // for(int i = 0; i<n; i++){
    //    cout<<i<<": "<<dp[i]<<"\n";
    //}
    cout<<dp[n-1]<<"\n";
       return;



     
}


int main() {
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}