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


const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    vector < long long > a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    if (n <= 3000) {
        vector < long long > dp(n + 1);
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                if ((((a[i] - a[j - 1]) % MOD + MOD) % MOD) % 2 == 0) {
                    dp[i] = (dp[i] + dp[j - 1]) % MOD;
                }
            }
        }
        cout << dp[n] << "\n";
    } else {
        int cnt[2];
        cnt[0] = 1;
        cnt[1] = 0;
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            ans = (ans + cnt[a[i] & 1]) % MOD;
            cnt[a[i] & 1]++;
        }
        cout << ans << "\n";
    }
}