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

using namespace std;
using LL = long long;

const int MOD = 1000000007;

int main()
{
	int n;

	cin >> n;

	vector<int> a(n);

	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}

	int sum = 0;
	bool ok = true;

	for (int i = 0; i < n; ++i)
	{
		sum += a[i];

		if (sum >= MOD)
		{
			ok = false;
			break;
		}
	}

	if (ok)
	{
		int cnt = 0;
		int sum = 0;

		for (int i = 0; i < n; ++i)
		{
			sum += a[i];

			if (sum % 2 == 0)
				++cnt;
		}

		int res = 0;

		if (sum % 2 == 0)
		{
			res = 1;

			for (int i = 1; i < cnt; ++i)
			{
				res = (res * 2) % MOD;
			}
		}

		cout << res << endl;
	}
	else
	{
		vector<int> dp(n + 1);
		dp[0] = 1;

		for (int i = 0; i < n; ++i)
		{
			LL rem = 0;

			for (int j = i; j >= 0; --j)
			{
				rem = (rem + a[j]) % MOD;

				if (rem % 2 == 0)
					dp[i + 1] = (dp[i + 1] + dp[j]) % MOD;
			}
		}

		cout << dp[n] << endl;
	}

	return 0;
}