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
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

inline int sgn(int x) {return x >= 0 ? 1 : -1;}

int modulo(int a, int p)
{
    int div_floor = a / p;
    if (sgn(a) * sgn(p) < 0)
        div_floor--;
    return a - p * div_floor;
}

const int MOD_NUM = 1000000007;

std::vector<int> prefix_sum;
std::vector<int> interval;
std::vector<int> dp;

int main()
{
    int n;
    scanf("%d", &n);
    prefix_sum.resize(n + 1);
    dp.assign(n + 1, 0);
    interval.resize(n);
    for (int i = 0; i < n; i++)
    {
        int value;
        scanf("%d", &value);
        interval[i] = value;
    }
    prefix_sum[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        prefix_sum[i] = (prefix_sum[i - 1] + interval[i - 1]) % MOD_NUM;
    }
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            //dp[i] += ((modulo((prefix_sum[i] - prefix_sum[j]), MOD_NUM) + 1) % 2) * dp[j];
            dp[i] += ((((prefix_sum[i] - prefix_sum[j] + MOD_NUM) % MOD_NUM) + 1) % 2) * dp[j];
            dp[i] %= MOD_NUM;
        }
    }
    printf("%d\n", dp[n]);
}