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
#include <iostream>
#include <vector>
using namespace std;
const int mod = 1000000007;
int main()
{
	int n;
	cin >> n;
	vector<int> A(n);
	for (auto &a: A) cin >> a;
	vector<int> S(n+1);
	S[0] = 0;
	for (int i=0; i<n; i++) {
		S[i+1] = (S[i] + A[i]) % mod;
	}

	vector<int> N(((long long)(n+1))*(n+1), -1);
	for (int l=0; l<n; l++) {
		for (int a=0; a<n-l; a++) {
			if (N[a*(n+1)+a+l+1] != -1) abort();
			int sum = 0;
			for (int m=0; m<=l; m++) {
				if ((mod + S[a+m+1] - S[a]) % mod % 2 == 0) {
					if (m==l) {
						sum++;
					} else {
						sum += N[(a+m+1)*(n+1)+a+l+1];
					}
				}
				sum %= mod;
			}
			N[a*(n+1)+a+l+1] = sum;
		}
	}
	cout << N[n] << endl;
	return 0;
}