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
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1e9 + 7; 
int n, a, sum = 0;
long long wyn = 0;
int tab[300007];
vector <pair<int,int>> v;
int pot2[300007];

void pot(int n)
{
	long long wyn = 1;
	pot2[0] = 1;
	for (int i = 1; i < n; i++)
	{
		wyn *= 2; 
		wyn %= MOD;
		pot2[i] = wyn; 
	}
}

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n; 

	pot(n);

	int ilen = 0;
	int ilep = 0;
	cin >> a;
	a %= MOD; 
	tab[0] = a % 2;
	sum += a % 2; 

	if (a % 2 == 1)	ilen++;
	else			ilep++;

	for (int i = 1; i < n; i++)
	{
		cin >> a;
		a %= MOD;
		tab[i] = a%2;
		sum += a % 2;
		if (a % 2 == 1)
		{
			ilen++;
			if (ilep != 0)
			{
				v.push_back({ ilep, 0 });
				ilep = 0;
			}
			if (i == n - 1)
			{
				v.push_back({ ilen,1 });
			}
		}

		else
		{
			ilep++;
			if (ilen != 0)
			{
				v.push_back({ ilen,1 });
				ilen = 0;
			}
			if (i == n - 1)
			{
				v.push_back({ ilep,0 });
			}
			
		}

	}
	
	if (n == 1)
	{
		if (sum % 2 == 0)	cout << "1\n";
		else				cout << "0\n";
	}
	else if (sum%2 == 1)
		cout << "0\n"; 
	else
	{

		int ile = 0;
		for (auto e : v)
		{
			if (e.second == 0)	ile += e.first; 
			else
			{
				if (e.first % 2 == 0)
				{
					int a = e.first; 
					a /= 2;
					ile += a; 
				}
			}
		}
		cout << pot2[ile - 1] << endl;
	}	
	return 0;
}

/*
4 
2 2 1 1




4
887549290 196060862 107633379 345344447

*/