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
#include <cstdio>

#define MAX_N 300005

long long P = 1000000007;

long long dp[MAX_N];
long long dane[MAX_N];
long long sumy[MAX_N];

long long int s(int a, int b) {
	return (sumy[b] - sumy[a - 1] + P) % P;
}

bool p(int a, int b) {
	return s(a, b) % 2 == 0;
}

void oblicz(int i) {
	if (i == 0) {
		dp[i] = 1;
	}

	for (int j = 1; j <= i; j++) {
		if (p(i-j+1, i)) {
			dp[i] = (dp[i] + dp[i-j]) % P;
		}
	}
}

int main() {
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%lld", &dane[i]);
		sumy[i] = (sumy[i-1] + dane[i]) % P;
	}

	for (int i = 0; i <= n; i++) {
		oblicz(i);
	}

	printf("%lld\n", dp[n]);

	return 0;
}