#include <iostream>
#include <ctime>
#include <cassert>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <iomanip>
#define nextLine() { for (int c = getchar(); c != '\n' && c != EOF; c = getchar()); }
#define sqr(a) ((a)*(a))
#define has(mask,i) (((mask) & (1<<(i))) == 0 ? false : true)

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...)
#endif

#define TASK "binary"
using namespace std;

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

#if ( _WIN32 || __WIN32__ )
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

typedef long long LL;
typedef long double ldb;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <bool> vb;
typedef vector <vb> vvb;

const int INF = (1 << 30) - 1;
const ldb EPS = 1e-9;
const ldb PI = fabsl(atan2l(0.0, -1.0));
const int MOD = 1000000007;
const int MAXN = 1111;

int n;
int z[MAXN];
void load() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &z[i]);
	}
}

vector <pii> g[MAXN];

int color[MAXN];
void dfs1(int v, int c) {
	color[v] = c;
	for (int i = 0; i < (int)g[v].size(); i++) {
		int to = g[v][i].fi;
		if (color[to] == -1) {
			dfs1(to, c);
		}
	}
}

int color2[MAXN];
void solve() {
	if (z[0] != 0 && z[0] != -1) {
		puts("0");
		return;
	}
	for (int i = 0; i < n; i++) {
		if (i + z[i] > n) {
			puts("0");
			return;
		}
	}
	for (int i = 1; i < n; i++) {
		if (z[i] == -1) {
			continue;
		}
		int u = 0;
		int v = i;
		for (int j = 0; j < z[i]; j++) {
			g[u].pb(mp(v, 0));
			g[v].pb(mp(u, 0));
			u++, v++;
		}
		if (v < n) {
			g[u].pb(mp(v, 1));
			g[v].pb(mp(u, 1));
		}
	}
	memset(color2, -1, sizeof(color2));
	for (int i = 0; i < (int)g[0].size(); i++) {
		int u = g[0][i].fi;
		color2[u] = g[0][i].se;
	}
	for (int i = 0; i < (int)g[0].size(); i++) {
		int u = g[0][i].fi;
		int c = g[0][i].se;
		for (int j = 0; j < (int)g[u].size(); j++) {
			int v = g[u][j].fi;
			if (color2[v] == -1) {
				continue;
			}
			if ((c ^ g[u][j].se ^ color2[v]) != 0) {
				puts("0");
				return;
			}
		}
	}
	memset(color, -1, sizeof(color));
	int cc = 0;
	for (int i = 0; i < n; i++) {
		if (color[i] == -1) {
			dfs1(i, cc++);
		}
	}
	int answer = 1;
	for (int i = 0; i < cc; i++) {
		answer = (answer * 2LL) % MOD;
	}
	printf("%d\n", answer);
}

int main() {
	clock_t start = clock();
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);
	load();
	solve();
	eprintf("time: %.3lf\n", (double)(clock() - start) / CLOCKS_PER_SEC);
	return 0;
}
