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
78
79
80
81
82
83
84
85
86
87
#include <bits/stdc++.h>

using namespace std;

using LL = long long;

LL MOD = 1e9+7;
const LL MAX = 300007;

LL arr[MAX];
LL prefsum[MAX];
LL DP2[MAX];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    LL sum = 0;
    bool b1 = true;

    for (int i = 1; i <= n; ++i)
    {
        int a;
        cin >> a;

        sum += a;
        arr[i] = a;
        prefsum[i] = prefsum[i - 1] + a;

        if (a > 100)
        {
            b1 = false;
        }
    }

    if (b1)
    {
        LL cnt = 0;

        if (prefsum[n] % 2 != 0)
        {
            cout << "0\n";
            return 0;
        }

        LL res = 1;

        for (int i = 1; i < n; ++i)
        {
            if (prefsum[i] % 2 == 0)
            {
                res = (res * 2) % MOD;
            }
        }

        cout << res << "\n";
        return 0;
    }
    else if (n <= 3000)
    {
        auto ok = [&](int a, int b)
        {
            return ((prefsum[b] - prefsum[a - 1]) % MOD) % 2 == 0;
        };

        DP2[0] = 1;

        for (int i = 1; i <= n; ++i)
        {
            for (int j = 1; j <= i; ++j)
            {
                if (ok(j, i))
                    DP2[i] = (DP2[i] + DP2[j - 1]) % MOD;
            }
        }

        cout << DP2[n] << "\n";
        return 0;
    }

    return 0;
}