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
#include <bits/stdc++.h>
using namespace std;
long long n, m, t[300005], sp[300005], dp[300005], mod = 1000000007;
long long compartment(long long a, long long b)
{
    a -= b;
    if(a < 0)
        a += mod;
    return a;
}
int main()
{
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &t[i]);
        sp[i] = sp[i - 1] + t[i];
        sp[i] %= mod;
    }
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= i; ++j)
        {
            if(compartment(sp[i], sp[i - j]) % mod % 2 == 0)
                dp[i] += dp[i - j];
            dp[i] %= mod;
        }
    }
    printf("%lld", dp[n]);
    return 0;
}