Problem:
 Score : 300 points    Problem Statement There are N people, conveniently numbered 1 through N .
They were standing in a row yesterday, but now they are unsure of the order in which they were standing.
However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.
According to their reports, the difference above for person i is A_i .  Based on these reports, find the number of the possible orders in which they were standing.
Since it can be extremely large, print the answer modulo 10^9+7 .
Note that the reports may be incorrect and thus there may be no consistent order.
In such a case, print 0 .      Constraints  1≦N≦10^5  0≦A_i≦N-1         Input The input is given from Standard Input in the following format:  N  A_1  A_2  ...  A_N       Output Print the number of the possible orders in which they were standing, modulo 10^9+7 .        Sample Input 1 5
2 4 4 0 2      Sample Output 1 4  There are four possible orders, as follows:   2,1,4,5,3  2,5,4,1,3  3,1,4,5,2  3,5,4,1,2        Sample Input 2 7
6 4 0 2 4 0 2      Sample Output 2 0  Any order would be inconsistent with the reports, thus the answer is 0 .       Sample Input 3 8
7 5 1 1 7 3 5 3      Sample Output 3 16

Solution (Python):
import collections

n = int(input())
a = list(map(int, input().split()))
ac = collections.Counter(a)
if n % 2 == 1:
    for i in ac:
        if i == 0:
            if ac[i] != 1:
                print(0)
                exit()
        else:
            if ac[i] != 2:
                print(0)
                exit()
    print((2 ** (n // 2)) % (10 ** 9 + 7))
else:
    for i in ac:
        if i == 0:
            if ac[i] != 0:
                print(0)
                exit()
        else:
            if ac[i] != 2:
                print(0)
                exit()
    print((2 ** (n // 2)) % (10 ** 9 + 7))

Solution (Python):
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

counter = defaultdict(int)
for a in A:
    counter[a] += 1

if N % 2 == 0:
    check = {i: 2 for i in range(1, N, 2)}
else:
    check = {i: 2 for i in range(2, N, 2)}
    check[0] = 1

unsatisfied = False
for key, val in counter.items():
    temp = check.get(key, None)
    if temp == None or temp < val:
        unsatisfied = True
        break

if unsatisfied:
    print(0)
else:
    print(2**(N//2) % mod)

Solution (Python):
from collections import Counter

MOD = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
if N % 2:
    if c[0] == 1 and all(c[i] == 2 for i in range(2, N, 2)):
        print(pow(2, (N // 2), MOD))
    else:
        print(0)
else:
    if all(c[i] == 2 for i in range(1, N, 2)):
        print(pow(2, (N // 2), MOD))
    else:
        print(0)

Solution (Python):
import math
n = int(input())
lis = list(map(int,input().split()))
li = [0 for _ in range(math.ceil(n / 2))]

for i in range(n):
  li[math.floor(lis[i] / 2)] += 1
for i in range(len(li)):
  if n % 2 == 1 and i == 0:
    if li[i] != 1:
      print("0")
      exit()
  else:
    if li[i] != 2:
      print("0")
      exit()
cou = 1
for i in range(math.floor(n/2)):
  cou *= 2
  cou %= (10 ** 9 + 7)
print(cou)

Solution (Python):
f = lambda: list(map(int,input().split()))
mod = 10**9+7

n = int(input())
a = sorted(f())
if n&1:
    if all([a[i] == i+i%2 for i in range(n)]):
        print(2**(n//2)%mod)
    else:
        print(0)
else:
    if all([a[i] == i+(i+1)%2 for i in range(n)]):
        print(2**(n//2)%mod)
    else:
        print(0)

Solution (Python):

n = int(input())
d = {}
for x in input().split(" "):
    x = int(x)
    if x not in d:
        d[x] = 0
    d[x] += 1


if n%2==0 and 0 in d:
    print(0)
    exit()
if n%2==1 and d[0]!=1:
    print(0)
    exit()

for k,v in d.items():
    if k==0:
        continue
    if v!=2:
        print(0)
        exit()

if 0 in d:
    del d[0]
m = len(d)
MOD = 10**9 + 7

ret = 1
for _ in range(m):
    ret = (ret*2)%MOD
print(ret)

Solution (Python):
n=int(input());print(pow(2,n//2,10**9+7)*(sorted(list(map(int,input().split())))==sorted(abs(n-1-i-i)for i in range(n))))

Solution (Python):
n=int(input());print(pow(2,n//2,10**9+7)if sorted(list(map(int,input().split())))==sorted(abs(n-1-i-i)for i in range(n))else 0)

Solution (Python):
n = int(input())
cnt = [0] * n
for i in input().split():
    cnt[int(i)] += 1
for i in range(1 + n % 2, n, 2):
    if cnt[i] != 2:
        print(0)
        exit(0)
print(pow(2, n // 2, int(1e9 + 7)))

Solution (Python):
n = int(input())

a = list(map(int,input().split()))
a.sort()
if n % 2 == 0:
    b = 0
    for i in range(0,n,2):
        if a[i] != a[i+1] and a[i] != i+1:
            b = 1
    if b == 1:
        print(0)
    else:
        print((2**(n//2))%1000000007)
else:
    b = 0
    if a[0] != 0:
        b = 1
    else:
        for i in range(1,n,2):
            if a[i] != a[i+1] and a[i] != i+1:
                b = 1
    if b == 1:
        print(0)
    else:
        print((2**(n//2))%1000000007)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
if n%2:
  b = [i for i in range(n-1, 0, -2)]*2
  b.append(0)
else:
  b = [i for i in range(n-1, 0, -2)]*2
if sorted(a)!=sorted(b):
  print(0)
else:
  print(pow(2, n//2, 10**9+7))

Solution (Python):
import sys
def coun(n):
  i = 0
  ans = 1
  while i < n:
    ans = (ans*2)%(10**9+7)
    i += 1
  return ans
N = int(input())
A = list(map(int, input().split()))
A.sort()
if len(A)%2 == 1:
  if A[0]!=0:
    print(0)
    sys.exit()
  i = 1
  while i <= len(A)//2:
    if A[2*i-1]==2*i and A[2*i]==2*i:
      i += 1
    else:
      print(0)
      sys.exit()
  print(coun(N//2))

if len(A)%2 == 0:
  i = 0
  while i < N//2:
    if A[2*i] == 2*i+1 and A[2*i+1] == 2*i+1:
      i += 1
    else:
      print(0)
      sys.exit()
  print(coun(N//2))

Solution (Python):
N = int(raw_input())
A = map(int, raw_input().split())

L = [ abs((N-1) - 2*i) for i in range(N)]

L.sort(); A.sort()

print pow(2, (N-N%2)/2, 10**9+7) if L == A else 0

Solution (Python):
N = int(raw_input())
A = map(int, raw_input().split())
 
L = [ abs((N-1) - 2*i) for i in range(N)]
 
L.sort()
A.sort()
 
print (2 ** ((N-N%2)/2) ) % (10**9+7) if L == A else 0

Solution (Python):
from collections import Counter

N = int(input())

A = Counter(list(map(int,input().split())))

mod = 1000000007

isok=True
for a in A:
    if a%2==0:
        if a==0:
            if A[a]!=1:
                isok=False
                break
        elif (N-1)%2!=0 or A[a]!=2:
                isok=False
                break
    else:
        if (N-1)%2!=1 or A[a]!=2:
            isok=False
            break

if isok:
    ans = 1
    for i in range(N//2):
        ans = (ans*2)%mod
    print(ans)
else:
    print(0)

Solution (Python):

n = int(input())
a = list(map(int, input().split()))
a.sort()
try:
    for i, a_i in enumerate(a):
        if n % 2 == 1:
            assert a_i == (i + 1) // 2 * 2
        else:
            assert a_i == i // 2 * 2 + 1
    answer = pow(2, n // 2, 10 ** 9 + 7)
except AssertionError:
    answer = 0
print(answer)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
is_even=True if n%2==0 else False
dic={}
for i in range(n):
    if a[i] in dic:
        dic[a[i]]+=1
    else:
        dic[a[i]]=1
if is_even:
    for m in dic.values():
        if m!=2:
            print(0)
            exit()
    else:
        print((2**(n//2))%1000000007)
else:
    if a.count(0)!=1:
        print(0)
        exit()
    else:
        dic[0]=2
        for m in dic.values():
            if m!=2:
                print(0)
                exit()
        else:
            print(2**(n//2)%1000000007)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
if n % 2 != 0:
    if a[0] != 0:
        print(0)
        quit()
    for i in range(n-1):
        if a[i+1] != (((i // 2) + 1) * 2):
            print(0)
            quit()
    for i in range((n-1) // 2):
        ans = (ans * 2) % (10**9 + 7)
    print(ans)
else:
    for i in range(n):
        if a[i] != (((i//2)*2)+1):
            print(0)
            quit()
    for i in range(n // 2):
        ans = (ans * 2) % (10**9 + 7)
    print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
flag = 0
check_ans = 0
check_in = 0
x = 1

if n == 1:
    if a[0] == 0:
        print(1)
    else:
        print(0)
elif n % 2 == 0:
    for i in range(n):
        check_ans += 2 * x - 1
        check_in += a[i]
        if check_ans != check_in:
            flag = 1
            print(0)
            break
        if i % 2 == 1:
            x += 1
    if flag == 0:
        print((2**int(n/2)) % (10**9+7))
else:
    for i in range(1, n):
        check_ans += 2 * x
        check_in += a[i]
        if check_ans != check_in:
            flag = 1
            print(0)
            break
        if i % 2 == 0:
            x += 1
    if flag == 0:
        print((2**int((n-1)/2)) % (10**9+7))

Solution (Python):

import math
from collections import Counter
N = int(input())
As = list(map(int, input().split()))
M = 10**9 + 7
cnt = Counter(As)
ans = 1
if N%2 == 0:
    for i in range(0,N//2):
        if cnt[i*2+1] != 2:
            print(0)
            exit()

else:
    for i in range(1,N//2):
        if cnt[i*2] != 2:
            print(0)
            exit()
    if cnt[0] != 1:
        print(0)
        exit()

p = N//2
for i in range(p):
    ans = (ans*2) % M

print(ans)

Solution (Python):
import collections


def func1(N):
    if N == 0:
        print(0)
    else:
        print((pow(2, int(N / 2)) % (pow(10, 9) + 7)))


def func2(G, N):
    G_list = list(G.values())

    if G_list.count(2) == len(G_list):
        N = N
    else:
        N = 0

    return N


def main():
    N = int(input())
    A = list(map(int, input().split()))
    G = dict(collections.Counter(A))

    if N % 2 == 1:
        if G[0] == 1:
            del G[0]
        else:
            N = 0

    N = func2(G, N)

    func1(N)


main()

Solution (Python):
from collections import Counter

N = int(input())
A = map(int, input().split())


mod = 10 ** 9 + 7

cnt = Counter(A)
if N % 2 == 0:
    if len(list(filter(lambda c: c != 2, cnt.values()))) != 0:
        print(0)
    else:
        print((2 ** (N // 2)) % mod)
else:
    if cnt[0] != 1:
        print(0)
    else:
        cnt.pop(0)
        if len(list(filter(lambda c: c != 2, cnt.values()))) != 0:
            print(0)
        else:
            print((2 ** (N // 2)) % mod)

Solution (Python):

import numpy as np
from collections import Counter
mo = 1000000007
r = range

n = int(input())
a = np.array(list(map(int, input().split())))

c = Counter(a.tolist())

if n % 2 == 1 and (0 not in c or c[0] != 1): print(0); exit();

for i in r(n//2):
    x = i * 2 + (1 if n % 2 == 0 else 2)
    if x not in c or c[x] != 2: print(0); exit();

print(2 ** (n//2) % mo)

Solution (Python):

import math
import sys
import itertools
import numpy as np
import functools
from collections import Counter
mo = 1000000007
r = range

n = int(input())
a = np.array(list(map(int, input().split())))

c = Counter(a.tolist())

if n % 2 == 1 and (0 not in c or c[0] != 1):
    print(0)
    exit()

for i in r(n//2):
    x = i * 2 + (1 if n % 2 == 0 else 2)
    if x not in c or c[x] != 2:
        print(0)
        exit()

print(2 ** (n//2) % mo)

Solution (Python):
from collections import *
n=input()
a=Counter(map(int,raw_input().split()))
s=1
if n&1:
    if 0 not in a or a[0]>1:
        print 0
        exit(0)
    s+=1
while s<n:
    if s not in a or a[s]!=2:
        print 0
        exit(0)
    s+=2
print pow(2,n/2,10**9+7)

Solution (Python):
MOD = 1000000007
def repeatSquares(x, n):  
  res = 1
  while n != 0:
    if n % 2 == 1:
      res *= x
      res %= MOD  
    x *= x
    n //= 2
    x %= MOD      
  return res

n = int(input())
A = list(map(int, input().split()))

dp = [0]*(n+1)
flag1 = True
for e in A:
  dp[e] += 1
if n % 2 == 0:
  for i in range(1, n):
    if i % 2 == 1:
      if dp[i] != 2:
        flag1 = False

  if flag1:
    ans = repeatSquares(2, n//2)
    print(ans)
  else:
    print(0)
else:
  for i in range(2, n):
    if i % 2 == 0:
      if dp[i] != 2:
        flag1 = False

  if flag1:
    ans = repeatSquares(2, n//2)
    print(ans)
  else:
    print(0)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]
C=[]

if N%2==0:
  for i in range(0,int(N/2)):
    B+=[2*i,2*i]
    C+=[2*i+1,2*i+1]
  if A==B or A==C:
    n=int(N/2)
    ans=2**n
    print(ans%(10**9+7))
  else:
    print(0)
else:
  B+=[0]
  C+=[1]
  for i in range(0,int(N/2)):
    B+=[2*i+2,2*i+2]
    C+=[2*i+3,2*i+3]
  if A==B or A==C:
    n=int((N-1)/2)
    ans=2**n

    print(ans%(10**9+7))
  else: 
    print(0)

Solution (Python):
mod = 10**9 + 7

N = int(raw_input())
A = map(int, raw_input().split())
A.sort(reverse = True)

ans = 1
for i in xrange(N/2):
    if A[2*i] == A[2*i + 1] == abs((N - 1 - i) - i):
        pass
    else:
        ans = 0
if ans:
    ans = pow(2, N/2, mod)
print ans

Solution (Python):


n = int(input())
lst = [int(e) for e in input().split(' ')]

lst = sorted(lst)
result = 1

valid_list = []
if n % 2 == 1:
    
    valid_list.append(0)
    for i in range(1, int((n + 1) / 2)):
        valid_list.append(i * 2)
        valid_list.append(i * 2)
    if lst == valid_list:
        for i in range(int((n - 1) / 2)):
            result = (result * 2) % 1000000007
        print(int(result))
    else:
        print(0)
else:
    for i in range(1, int((n / 2) + 1)):
        valid_list.append((i * 2) - 1)
        valid_list.append((i * 2) - 1)
    if lst == valid_list:
        for i in range(int(n / 2)):
            result = (result * 2) % 1000000007
        print(int(result))
    else:
        print(0)

Solution (Python):

num_N = int(input())
l_num = list(map(int, input().split()))
l_num.sort()

num_div = num_N // 2

if num_N % 2 == 1:
    l_cor = [0]
    for i in range(1, num_div + 1):
        l_cor.append(i * 2)
        l_cor.append(i * 2)

else:
    l_cor = []
    for i in range(1, num_div + 1):
        l_cor.append(2 * i - 1)
        l_cor.append(2 * i - 1)

if l_num == l_cor:
    print((2 ** num_div) % (10 ** 9 + 7))

else:
    print(0)

Solution (Python):
from collections import defaultdict
length = int(input())
num_list = defaultdict(int)
target = [int(n) for n in input().split(" ")]

for t in target:
    num_list[t] += 1
if length == 1 and target[0] == 0:
    print(1)
elif length % 2 == 1:
    for k,v in num_list.items():
        if k % 2 != 0 or (k != 0 and v != 2) or (k == 0 and v != 1):
            print(0)
            break
    else:
        print((2**(length//2)) % (10**9 + 7))
else:
    for k,v in num_list.items():
        if k % 2 != 1 or (k != 0 and v != 2) or (k == 0 and v != 1):
            print(0)
            break
    else:
        print((2**(length//2)) % (10**9 + 7))

Solution (Python):
n=input()
a=map(int, raw_input().split())
a.sort()
cur = 1
if n % 2 == 1:
    if a[0] != 0:
        print 0
        exit(0)
    n -= 1
    a = a[1:]
    cur += 1
    
for i in xrange(n / 2):
    if a[i * 2] != cur or a[i * 2 + 1] != cur:
        print 0
        exit(0)
    cur += 2
print pow(2, n / 2, 1000000007)

Solution (Python):
n=int(input())
a=list(sorted(map(int,input().split())))
def valid():
    cur=(n+1)&1
    for i in range(n):
        if n&1==0 and i&1==0 and i>0:
            cur+=2
        if n&1==1 and i&1==1:
            cur+=2
        if a[i] != cur: return False
    return True
print(2**(n//2)%(10**9+7) if valid() else 0)

Solution (Python):
n=int(input())
a=map(int,input().split())
def valid():
    b = list(range((n+1)&1, n+1, 2))
    for i in range(len(b)-1, -1, -1):
        b.insert(i, b[i])
    if b[0] == 0:
        b = b[1:]
    return list(sorted(a)) == b
ans,mod = 1,10**9+7
for i in range(n//2):
    ans = (ans * 2) % mod
print(ans if valid() else 0)

Solution (Python):
import sys
from collections import Counter
n = input()
a = [int(x) for x in raw_input().split()]
a.sort()
if n == 1:
    if a[0] == 0:
        print 1
        sys.exit()
c = 0
if n&1:
    if a[0] == 0:
        del a[0]
        d = Counter(a)
        for i in d.keys():
            if i == 0:
                print 0
                sys.exit()
            if i&1:
                print 0
                sys.exit()
            if not(i&1):
                if d[i] == 2:
                    c += 1
                if d[i] != 2:
                    print 0
                    sys.exit()
    if c == (n-1)//2:
        print (1 << c)%(10**9+7)
if not(n&1):
    d = Counter(a)
    for i in d.keys():
        if i&1:
            if d[i] == 2:
                c +=1
            if d[i] != 2:
                print 0
                sys.exit()
        if not(i&1):
            print 0
            sys.exit()
    if c == n//2:
        print (1 << c)%(10**9+7)

Solution (Python):
def solve(n,a):
    ct = [0 for _ in range(n)]
    for v in a:
        ct[v] += 1

    if n%2 == 1:
        if ct[0] != 1:
            return 0

        for i in range(1,n):
            if i%2 == 1:
                if ct[i] != 0:
                    return 0
            else:
                if ct[i] != 2:
                    return 0
    else:
        if ct[0] != 0:
            return 0

        for i in range(1,n):
            if i%2 == 1:
                if ct[i] != 2:
                    return 0
            else:
                if ct[i] != 0:
                    return 0

    return 2**(n//2)%(10**9+7)

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(solve(n,a))

if __name__ == '__main__':
    main()

Solution (Python):
import sys

cin = sys.stdin


MODULO = int(10**9+7)
N = int(cin.readline())
A = list(map(int, cin.readline().split()))
pos = [0]*(N+1)
if (N%2==1):
    pos[0]=1
for ai in A:
    if (ai+N)%2==0 or ai>=N or ai<0:
        print(0)
        exit()
    pos[ai]+=1
    if pos[ai]>2:
        print(0)
        exit()
cnt = 1
for i in range(N//2):
    cnt = cnt * 2 % MODULO
print(cnt)

Solution (Python):
N = int(raw_input())
A = list(map(int,raw_input().split()))
A.sort()
MOD = 10**9 + 7
def calc(a):
	if N % 2 == 0:
		B = [int(i/2)*2 + 1 for i in range(0,N)]
		if A != B:
			return 0
	else:
		B = [int(i/2)*2 for i in range(1,N+1)]
		if A != B:
			return 0
	return 2 ** int(N/2)

print(calc(A) % MOD)

Solution (Python):
N = int(input())
A = map(int, input().split())

if N%2 == 0:
    count = [(2 if i%2 == 1 else 0) for i in range(N)]
else:
    count = [(2 if i%2 == 0 else 0) for i in range(N)]
    count[0] = 1

for a in A:
    count[a] -= 1
    if count[a] < 0:
        print(0)
        break
else:
    print(2**(N//2)%(10**9+7))

Solution (Python):

from collections import Counter

def maybe_check(n,A):
    try:
        if n <= 0 or n > 100000:
            raise

        div = 1000000007
        maybe_list = [abs(abs(i - n) - ((n -1 ) - abs(i - n))) for i in range(1, n+1)]
        maybe_list.sort()
        A.sort()
        if A !=  maybe_list:
            raise

        pattern = len([num for num,count in Counter(maybe_list).items() if count != 1])
        return (2 ** pattern) % div

    except:
        return 0


_n = int(raw_input())
_A = map(int,raw_input().split())

print maybe_check(_n,_A)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def main():
    n = int(input())
    a = list(map(int, input().split()))
    r = 0
    a.sort()
    if n % 2 == 1:
        if a[0] != 0:
            return 0
        r = 1
        for i in range(n//2):
            if a[i*2+1] == a[i*2+2] and a[i*2+1] == i*2+2:
                r = r*2 % mod
            else:
                return 0
    else:
        r = 1
        for i in range(n//2):
            if a[i*2+1] == a[i*2] and a[i*2+1] == i*2+1:
                r = r*2 % mod
            else:
                return 0

    return r


print(main())

Solution (Python):



from collections import Counter
import sys
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7
A = Counter(A)

if N % 2 == 1:
    for num, cnt in A.items():
        
        if num == 0:
            if cnt != 1:
                print(0)
                sys.exit()
        else:
            if not (num % 2 == 0 and cnt == 2):
                print(0)
                sys.exit()
    print((2 ** (N // 2)) % MOD)
else:
    for num, cnt in A.items():
        
        if not (num % 2 == 1 and cnt == 2):
            print(0)
            sys.exit()
    print((2 ** (N // 2)) % MOD)

Solution (Python):
def get_possible(n, people):
    counts = {}
    values = set([])
    for person in people:
        if not counts.get(person):
            counts[person] = 1
            values.add(person)
        else:
            counts[person] += 1
 
    
    if n % 2:
        start_value = 0
    else:
        start_value = 1
 
    if values != set([i for i in xrange(start_value, n , 2)]):
        return 0
 
    possibilities = 1
 
    if 0 in values:
        values.remove(0)
 
    for key in list(values):
        if counts.get(key) != 2:
            return 0
        else:
            possibilities *= counts.get(key)
 
    return possibilities
 
 
 
if __name__ == "__main__":
    n = int(raw_input())
    people = map(int, raw_input().split(' '))
    print (get_possible(n, people) % (10**9 + 7))

Solution (Python):
from collections import Counter

n = int(input())
a = Counter(map(int, input().split()))
      

if n % 2 == 0:
    f = True
    for k in a.values():
        f &= k == 2
    if f:
        print(pow(2, n // 2, 10 ** 9 + 7))
    else:
        print(0)
else:
    f = True
    a[0] += 1
    for k in a.values():
        f &= k == 2
    if f:
        print(pow(2, n // 2, 10 ** 9 + 7))
    else:
        print(0)

Solution (Python):
import math, sys

N = int(input())
a = list(map(int, input().split()))

p = [0] * math.ceil(N / 2)

even = (N & 1 == 0)

for i in range(N):
    p[ int((a[i] - even) / 2) ] += 1


if (even and p[0]!=2) or (not even and p[0]!=1):
    print(0)
    sys.exit()
    
ans = p[0]
for i in range(1, len(p)):
    val = p[i]
    if val!=2:
        print(0)
        sys.exit()
    ans = (ans * p[i]) % 1000000007

print(ans)

Solution (Python):


D = 10**9+7
N = int(input())
A = list(map(int, input().split()))
M = N%2>0
b = 1
C = [0] * (N//2+1)
if M:
    for i in A:
        if i%2 < 1:
            C[i//2] += 1 
    b = (N//2) == sum(1 for x in C[1:] if x == 2) and C[0] == 1
    
else:
    for i in A:
        if i%2 > 0:
            C[i//2] += 1 
    b = (N//2) == sum(1 for x in C if x == 2)

print((2**(N//2))%D if b else 0)

Solution (Python):
import math



N = int(raw_input())
A = map(int, raw_input().split())
B = [0] * N



bad = False

for a in A:
    if N % 2 == 0: 
        if a % 2 == 0: 
            bad = True
            break

    else:
        if a % 2 == 1:
            bad = True
            break

    r = (a + N - 1) / 2
    leftbig = r
    rightbig = N-1-r



    if leftbig < N and B[leftbig] < 1:
        B[leftbig] = 1
    else:
        if rightbig >= N: 
            bad = True
            break

        if B[rightbig] < 1:
            B[rightbig] = 1
        else:
            bad = True
            break

if bad:
    print '0'
else:
    if N % 2 == 0:
        print pow(2, N/2, 10**9+7)
    else:
        print pow(2, (N-1)/2, 10**9+7)

Solution (Python):



P = 10 ** 9 + 7


def count_perms(n, xs, mod=P):
    if n % 2 == 0:
        std = sorted(list(range(1, n, 2)) * 2)
    else:
        std = sorted([0] + list(range(2, n, 2)) * 2)
    if sorted(xs) != std:
        return 0
    elif n % 2 == 0:
        return pow(2, (n - 2) // 2 + 1, mod)
    else:
        return pow(2, (n - 1) // 2, mod)


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    print(count_perms(n, xs))


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
A.reverse()
if N % 2:
	B = [i for i in range(2,N,2)]*2
	B.sort()
	B.reverse()
	B.append(0)
else:
	B = [i for i in range(1,N,2)]*2
	B.sort()
	B.reverse()
if A == B:
	ans = 2**(N//2)
else:
	ans = 0
print(ans%(10**9+7))

Solution (Python):
n = int(raw_input())
a = sorted(map(int, raw_input().split()))

x = []
if n % 2 == 0:
    for i in range(1, n, 2):
        x.extend([i, i])
else:
    x.append(0)
    for i in range(2, n, 2):
        x.extend([i, i])

if a == x:
    if n % 2 == 0:
        print (2 ** (n/2)) % (10 ** 9 + 7)
    else:
        print (2 ** ((n-1)/2)) % (10 ** 9 + 7)
else:
    print 0

Solution (Python):


n = input()
a = [int(i) for i in raw_input().split()]
a.sort()

ok = True

if(n%2==0):
    for i in range(n):
        if(a[i]!=(i/2*2+1)):
            ok = False

if(n%2==1):
    for i in range(n):
        if(a[i]!=((i+1)/2*2)):
            ok = False


if(ok):
    print 2**(n/2)%1000000007
        
else:
    print '0'

Solution (Python):
n = input()
a = map(int,raw_input().split())
m = 1000000007

c = [0]*n
ct = 1
for x in a:
    p1 = (n-1+x)/2
    p2 = (n-1-x)/2
    c[p1] += 1
    c[p2] += 1
    if (c[p1]<2 and c[p2]<2):
        ct *= 2
        ct = ct%m
    elif (c[p1]>2 and c[p2]>2):
        ct = 0
        break
print ct

Solution (Python):
n = input()
a = map(int, raw_input().split())
a = sorted(a)
c = 1
i = 0
if n%2 == 0:
    k = 1
    while i < len(a):
        if not a[i] == a[i+1] == k:
            print 0
            exit()
        c *= 2
        c %= 10**9 + 7
        i += 2
        k += 2
else:
    if not a[0] == 0:
        print 0
        exit()
    k = 2
    i = 1
    while i < len(a):
        if not a[i] == a[i+1] == k:
            print 0
            exit()
        c *= 2
        c %= 10**9 + 7
        i += 2
        k += 2
print c

Solution (Python):
N = input()
A = map(int, raw_input().split())
C = [0]*N
for a in A:
    C[a] += 1
ok = True
if N%2==0 and C[0]!=0 or N%2!=0 and C[0]!=1:
    ok = False
for i in range(N%2+1, N, 2):
    if C[i]!=2:
        ok = False
print 2**(N/2)%(10**9+7) if ok else 0

Solution (Python):
import collections

def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    ac = dict(collections.Counter(a))

    if n % 2 == 0:
        if 0 in ac:
            return 0
    else:
        if 0 not in ac or ac[0] != 1:
            return 0
        else:
            del ac[0]
    ans = 1

    for k, v in ac.items():
        if (k + n) % 2 == 1 and v == 2:
            ans = (ans * 2) % 1000000007
        else:
            return 0

    return ans

print(solve())

Solution (Python):
from sys import stdin
import math
n = int(stdin.readline())
di = {}
a = map(int,stdin.readline().split())
for i in a:
    di[i] = di.get(i,0)+1
valid = 1

if n%2:
    if di.get(0,0)!=1:
        valid = 0
        
    else:
        for i in di:
            if i==0:
                continue
            if i >=n:
                valid = 0
                break
            if i%2:
                valid = 0
                break
            if di.get(i,0)!=2:
                valid = 0
                break
else:
    for i in di:
        if i>=n:
            break
        if i%2==0:
            valid = 0
            break
        if di.get(i,0)!=2:
            valid = 0
            break
if valid:
    print pow(2,n/2,10**9 + 7)
else:
    print 0

Solution (Python):

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

MOD = 10**9 + 7

n()
A = ln()

L = len(A)

A.sort()

if L % 2 == 1:
    c = A[0]
    del A[0]
    B = A[1::2][::-1] + [c] + A[0::2]
else:
    B = A[1::2][::-1] + A[0::2]

for i in xrange(L):
    j = L - i - 1
    if abs(i - j) != B[i]:
        print 0
        break
else:
    print pow(2, len(A) / 2, MOD)

Solution (Python):
n=int(raw_input())
a=map(int,raw_input().split())
a.sort()
if n%2==0:
    i=0
    j=-1
    while i<n-1:
        j+=1
        if a[i]==a[i+1]==2*j+1:
            i+=2
            continue
        else:
            print(0)
            exit()
    print(pow(2,n/2,10**9+7))
else:
    i=1
    j=0
    while i<n-1:
        j+=1
        if a[i]==a[i+1]==2*j:
            i+=2
            continue
        else:
            print(0)
            exit()
    print(pow(2,(n-1)/2,10**9+7))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
	sta=[1,1]
	s=3
else:
	sta=[0]
	s=2

for i in range(s,n)[::2]:
	sta.append(i)
	sta.append(i)

if sorted(sta)!=sorted(a):
	print(0)
	exit()

i=int(n/2)
print(pow(2,i,10**9+7))

Solution (Python):
n = input()
A = map(int, raw_input().split())
C = [0]*((n+1)/2)
MOD = 10**9+7
for e in A:
    C[e/2] += 1
if n%2 == 1:
    if C[0] != 1 or any(C[i] != 2 for i in xrange(1, (n+1)/2)):
        print 0
        exit(0)
    print pow(2, (n-1)/2, MOD)
if n%2 == 0:
    if any(C[i] != 2 for i in xrange((n+1)/2)):
        print 0
        exit(0)
    print pow(2, n/2, MOD)

Solution (Python):
import collections
n = int(input())
a = list(map(int, input().split()))

MOD = 10**9 + 7
cnt = collections.Counter(a)
if n%2 == 0:
    ans = 1
    for i in range(1,n, 2):
        if cnt[i] == 2:
            ans = ans*2%MOD
        else:
            print(0)
            exit()
else:
    ans = 1
    for i in range(2,n, 2):
        if cnt[i] == 2:
            ans = ans*2%MOD
        else:
            print(0)
            exit()
    if cnt[0] != 1:
        print(0)
        exit()
print(ans)

Solution (Python):


N = int(input())
N_orig = N
As = list(map(int,input().split()))
As.sort()

Bs = []
if N % 2 == 1:
    Bs.append(0)
    N -= 1
    b = 2
else:
    b = 1

while N > 0:
    Bs.append(b)
    Bs.append(b)
    N -= 2
    b += 2

if As != Bs:
    print(0)
else:
    print(pow(2, N_orig // 2, 1000000007))

Solution (Python):
from collections import Counter
N = int(raw_input())
A = sorted(map(int, raw_input().split()))
mod = 10**9+7

if N%2 == 1:
    if A[0] != 0:
        print 0
        exit()
    x = 2
    for i in xrange(1, N, 2):
        if A[i] != x or A[i+1] != x:
            print 0
            exit()
        x += 2
    print pow(2, N/2, mod)
else:
    x = 1
    for i in xrange(0, 2, N):
        if A[i] != x or A[i+1] != x:
            print 0
            exit()
        x += 2
    print pow(2, N/2, mod)