//#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#define mp make_pair
#define pb push_back

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

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

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

using namespace std;

#define TASKNAME "binary"

#ifdef LOCAL
static struct __timestamper {
	~__timestamper(){
        TIMESTAMP(end);
	}
} __TIMESTAMPER;
#endif

typedef long long ll;
typedef long double ld;

const int MAXN = 1100;

vector<int> g[MAXN];
vector<int> ty[MAXN];

int color[MAXN];
int z[MAXN];

int ans, n;

void addEdge(int u, int v, int t){
    g[u].pb(v);
    ty[u].pb(t);
    g[v].pb(u);
    ty[v].pb(t);
}

void dfs(int v,int c){
   if (color[v] != -1){
      if (color[v] != c) ans = 0;
      return;
   }
   color[v] = c;
   for (int i = 0; i < (int)g[v].size(); i++)
      dfs(g[v][i], c ^ ty[v][i]);
}


int main(){
  freopen(TASKNAME".in","r",stdin);
  freopen(TASKNAME".out","w",stdout);

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

  for (int i = 1; i < n; i++){
  	  if (z[i] == -1) continue;
  	  if (i + z[i] > n) {
  	     printf("0\n"); 
  	     return 0;
  	  }
  	  for (int j = 0; j < z[i]; j++)
  	     addEdge(j, j+i, 0);
  	  if (i + z[i] != n)
  	     addEdge(z[i], i+z[i], 1);
  }

  memset(color, -1, sizeof(color));
  ans = 1;
  for (int i = 0; i < n; i++)
  	if (color[i] == -1){
  	   dfs(i, 0);
  	   ans = (ans * 2) % 1000000007;
  	}

  printf("%d\n", ans);
  return 0;
}