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
#include <iostream>

using namespace std;

const int SIZE = 300001,
          DIV  = 1000000007;

int n, c;
int arr[SIZE],
    dp[SIZE];

int combs(int id = 1, int val = arr[1]) {
    if(id == n) {
       if((val % DIV) % 2 == 0)
           return 1;
       else
           return 0;
    }

    if((val % DIV) % 2 == 0) {
        if(dp[id + 1] == -1)
            dp[id + 1] = combs(id + 1, arr[id + 1] % DIV);
        return dp[id + 1] + combs(id + 1, (val + arr[id + 1]) % DIV);
    }
    else
        return combs(id + 1, (val + arr[id + 1]) % DIV);
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> arr[i];

    for(int i = 0; i <= n; i++) dp[i] = -1;
    cout << combs() << "\n";
}