#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

template<typename a>
struct S009 {
  a pow(a x, long n) {
    if( n == 0 ) return a(1);
    a t = pow(x, n / 2);
    return t * t * (n % 2 ? x : a(1));
  }
};

template<long p = 1000000007>
struct S010 {
  long x;
  S010() : x(0) {}
  S010(long x_) : x(x_ % p) {}
  S010 operator + (S010 y) { return S010<p>((x + y.x) % p); }
  S010 operator += (S010 y) { x = (x + y.x) % p; return *this; }
  S010 operator - (S010 y) { return S010<p>((x - y.x) % p); }
  S010 operator -= (S010 y) { x = (x - y.x) % p; return *this; }
  S010 operator * (S010 y) { return S010<p>((x * y.x) % p); }
  S010 operator *= (S010 y) { x = (x * y.x) % p; return *this; }
  S010 operator / (S010 y) { S009<S010> s; return *this * s.pow(x, p - 2); }
  S010 operator /= (S010 y) { S009<S010> s; x = (*this * s.pow(x, p - 2)); return *this; }
};
template<long p>
S002& operator >= (S002& r, S010<p>& x) {
  long y;
  r >= y;
  x = S010<p>(y);
  return r;
}

template<typename a>
struct S017 {
  std::vector<a> xs;
  S017(const std::vector<a>& ys, long m) {
    xs.resize(m+1);
    for(a x : ys) {
      xs[x] += 1;
    }
  }
  a operator [] (long i) {
    return xs[i];
  }
};

struct Solver {
  long n;
  std::vector<long> xs;
  Solver() {
    S002 r;
    r >= n >n>= xs;
  }
  void solve() {
    S017<long> ys(xs, n);
    long w = 0;
    for(long i = 1 - (n % 2); i < n; i+=2) {
      if( not (( i == 0 and ys[i] == 1 ) or ( i != 0 and ys[i] == 2 )) ) {
        puts("0");
        return;
      }
      if( i != 0 ) w += 1;
    }
    S009<S010<>> s;
    printf("%ld\n", (s.pow(S010<>(2), w)).x);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 1792