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 sys
from collections import Counter
MOD = 10 ** 9 + 7
n, *a = map(int, sys.stdin.read().split())

def main():
  c = Counter(a)
  if n & 1:
    if c[0] != 1:
      print(0); return
  for i in range(1 + (n & 1), n, 2):
    if c[i] != 2:
      print(0); return 
  print(pow(2, n // 2, MOD))

if __name__ ==  '__main__':
  main()

Solution (Python):
import sys
from collections import Counter
MOD = 10 ** 9 + 7
n, *a = map(int, sys.stdin.read().split())

def main():
  c = Counter(a)
  if n & 1:
    if c.get(0, 0) != 1:
      print(0); return
  for i in range(1 + (n & 1), n, 2):
    if c.get(i, 0) != 2:
      print(0); return 
  print(pow(2, n // 2, MOD))

if __name__ ==  '__main__':
  main()

Solution (Python):
import sys
from collections import Counter
MOD = 10 ** 9 + 7
n, *a = map(int, sys.stdin.read().split())

def main():
  c = Counter(a)
  ans = 0
  if n & 1:
    for i in range(2, n, 2):
      if c[i] != 2: break
    else:
      if c[0] == 1:
        ans = pow(2, n // 2, MOD)
  else:
    for i in range(1, n, 2):
      if c[i] != 2: break
    else:
      ans = pow(2, n // 2, MOD)
  print(ans)

if __name__ ==  '__main__':
  main()

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

def calc():
    c = Counter(A)
    if N % 2 == 0:
        for i, v in c.items():
            if i % 2 == 0:
                return 0
            if v != 2:
                return 0
    else:
        for i, v in c.items():
            if i % 2 == 1:
                return 0
            if i == 0 and v == 1:
                continue
            if v != 2:
                return 0
    return pow(2, N//2, 10**9+7)

print(calc())

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
MOD = 10 ** 9 + 7
corrct = []
t = N - 1
for i in range(N):
    corrct.append(t)
    if i % 2 == 1:
        t -= 2

if all(corrct[i] == A[i] for i in range(N)):
    print(pow(2, N//2, MOD))
else:
    print(0)

Solution (Python):
import numpy as np
N = int(input())
a = np.array(list(map(int,input().split())), dtype=np.int32)
a = np.sort(a)
b = np.diff(a)
c = np.array([2,0]*(N//2), dtype=np.int32)
if N%2==0:
    c = np.array([0] + [2,0]*((N-1)//2), dtype=np.int32)

if (b==c).all():
    res = (pow(2, (N-1)//2, 10**9+7) * ((N+1)%2+1)) % (10**9+7)
    print(res)
else:
    print(0)

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:
    return a
  return gcd_(a,a % b) 
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))

def main():
  n = int(input())
  A = readInts()
  A = sorted(A)
  ans = 0
  if n%2==1:
    A.remove(0)
  if A[0::2]==A[1::2]:
    ans = 2**(n//2)%(10**9+7)
  print(ans)
if __name__ == '__main__':
  main()

Solution (Python):
import sys

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










acnt=[0]*n

for i in range(n):
    acnt[a[i]]=acnt[a[i]]+1
    
mod=10**9+7   
if n%2==0:
    for i in range(1,n,2):
        if acnt[i]!=2:
            print(0)
            sys.exit()
    print(pow(2,n//2,mod))
elif n%2==1:
    if acnt[0]!=1:
        print(0)
    else:
        for i in range(2,n,2):
            if acnt[i]!=2:
                print(0)
                sys.exit()
        print(pow(2,n//2,mod))

Solution (Python):
import sys
import math
in1 = sys.stdin.readlines()
"""
in1 = ['8','7 5 1 1 7 3 5 3']
in1 = ['7','6 4 0 2 4 0 2']
in1 = ['5','2 4 4 0 2']
"""
p = 10 ** 9 + 7
N = int(in1[0])
A_N = list(map(int, in1[1].split()))
A_N.sort()

ckA = []
if N % 2 == 1:
    ckA.append(0)
    oddFlag = 1
else:
    oddFlag = 0

for idx1 in range(1 + oddFlag, N, 2):
    ckA.append(idx1)
    ckA.append(idx1)

if ckA != A_N:
    print(0)
else:
    print((2 ** ((N - oddFlag) // 2)) % p)

Solution (Python):
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
l=[]
c=Counter(A)
flag=1
ans=1
values=list(c.values())	
key=list(c.keys())	
p=10**9+7
for i in range(len(key)):
    l.append([key[i],values[i]])
l.sort(key=lambda x:x[0])
for i in range(len(key)):
    if N%2==0:
        if (l[i][0]%2==1)and(0<l[i][0]<N)and(l[i][1]==2):
            ans=(ans*2)%p
        else:
            flag=0
            break
    else:
        if (l[i][0]==0)and(l[i][1]==1):
            ans=ans
        elif (l[i][0]%2==0)and(0<l[i][0]<N)and(l[i][1]==2):
            ans=(ans*2)%p
        else:
            flag=0
            break
if flag==1:
    print(ans%p)
else:
    print("0")

Solution (Python):
import sys
sys.setrecursionlimit(10**5)


def pow_mod(n,k,m):
    if k==0:
        return 1
    if k&1:
        return (pow_mod(n,k-1,m)*n%m)%m
    else:
        return (pow_mod(n,k//2,m)**2)%m

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





if N&1:
    if A[0]!=0:
        print(0)
        exit()

    for i in range(1,N,2):
        if A[i]!=A[i+1] or A[i]!=i+1:
            print(0)
            exit()
    print(pow_mod(2,((N-1)//2),MOD))

else:
    for i in range(0,N,2):
        if A[i]!=A[i+1] or A[i]!=i+1:
            print(0)
            exit()
    print(pow_mod(2,N//2,MOD))

Solution (Python):
import sys
"""
奇数の場合は0が一つと偶数番号が2個ずつ存在している
偶数の場合は奇数番号が2個ずつ並んでいる
それらの条件を満たす場合に、並び替えることが可能で、
"""

N = int(input())
L = list(map(int, input().split()))
number_dict = {}

MOD = 10 ** 9 + 7

for l in L:
  if l in number_dict:
    number_dict[l] += 1
  else:
    number_dict[l] = 1

if N%2 ==1:
  if 0 in number_dict and number_dict[0] != 1:
    print(0)
    sys.exit()
  number_dict.pop(0)
  ran = range(2, N, 2)
else:
  ran = range(1, N, 2)


for i in ran:
  if i not in number_dict:
    print(0)
    sys.exit()
  if number_dict[i] != 2:
    print(0)
    sys.exit()
  number_dict.pop(i)


if len(number_dict.keys()) == 0:
  print(2**int(N/2) % MOD )
else:
  print(0)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
from fractions import gcd
from math import ceil
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations
ans = 0
d = Counter(A)
if N%2==1:
    for i in range(0,N,2):
        
        if i==0:
            if d[i]!=1:
                
                break
        elif d[i]!=2:
            
            break
    else:
        ans = pow(2,(N-1)//2,10**9+7)
else:
    for i in range(1,N,2):
        if d[i]!=2:
            
            break
    else:
        ans = pow(2,N//2,10**9+7)
print(ans)

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

t = list(map(int,input().split()))

if n%2==0:
    memo = [0]*n
    for i in t:
        memo[i] += 1
    for j in range(n):
        if j%2==1 and memo[j] != 2:
            print(0)
            exit()
    print((2**(n//2))%mod)  
else:
    memo = [0]*n
    for i in t:
        memo[i] += 1
    if memo[0] != 1:
        print(0)
        exit()
    memo[0]+=1
    for j in range(n):
        if j%2==0 and memo[j] != 2:
            print(0)
            exit()
    print((2**((n-1)//2))%mod)

Solution (Python):
import sys
from collections import deque


mod = 10**9 + 7
n = int(input())
a = deque(sorted(list(map(int, (input().split())))))
if n % 2 == 0:
    for i in range(n//2):
        b = a.popleft()
        c = a.popleft()
        if b != i*2+1 or c != i*2+1:
            print(0)
            sys.exit()
    print(pow(2, n//2, mod))

if n % 2 == 1:
    if a.popleft() != 0:
        print(0)
        sys.exit()
    for i in range(n//2):
        b = a.popleft()
        c = a.popleft()
        if b != (i+1)*2 or c != (i+1)*2:
            print(0)
            sys.exit()
    print(pow(2, n//2, mod))

Solution (Python):
N = int(input())
A = map(int, input().split())
l = [abs(N - (n * 2 + 1)) for n in range(N)]

if sorted(A) == sorted(l):
    print(pow(2, N//2) % (pow(10,9) + 7))
else:
    print(0)

Solution (Python):
N = int(input())
A = map(int, input().split())
l = [abs(N - (n * 2 + 1)) for n in range(N)]

if sorted(A) == sorted(l):
    print(pow(2, int(N/2)) % (pow(10,9) + 7)) 
else:
    print(0)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
count=0
ans=1
A.sort()
if(N%2==0):
  flag=True
  for i in range(N):
    if(i%2==0):
      if(A[i]!=i+1):
        flag=False
        break
    else:
      if(A[i]!=i):
        flag=False
        break
      else:
        ans=(ans*2)%(10**9+7)
else:
  flag=True
  if(A[0]!=0):
    flag=False
  for i in range(N):
    if(i%2==1):
      if(A[i]!=i+1):
        flag=False
        break
    else:
      if(A[i]!=i):
        flag=False
        break
      else:
        if(i>0):
          ans=(ans*2)%(10**9+7)
if(flag==True):
  print(ans)
else:
  print(0)

Solution (Python):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n=int(input())
a=list(map(int,input().split()))
lst=[0]*n
for i in range(n):
    lst[a[i]]+=1

for i in range(n):
    if n%2==0:
        if i%2==0 and lst[i]!=0:
            break
        elif i%2==1 and lst[i]!=2:
            break
    else:
        if i%2==1 and lst[i]!=0:
            break
        elif i%2==0:
            if i==0:
                if lst[i]!=1:
                    break
            elif lst[i]!=2:
                break
else:
    print(pow(2,n//2,mod))
    exit()
print(0)

Solution (Python):
from collections import Counter

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

for k, v in c.items():
    if v != 2:
        if N % 2 == 1 and k == 0:
            continue
        else:
            print("0")
            break
else:
    print(2 ** (N // 2) % MOD)

Solution (Python):
MOD=1000000007
N=int(input())
A=sorted(list(map(int,input().split())))
m=N%2
if m==1 and A[0]!=0:
  print(0)
else:
  for i in range(N//2):
    if A[2*i+m]==A[2*i+1+m]==2*i+1+m:
      continue
    else:
      print(0)
      exit()
  print(2**(N//2)%MOD)

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

Solution (Python):




import sys
input = sys.stdin.readline



def main():
    N = int(input())
    A = list(map(int,input().split()))

    mod = 10 ** 9 + 7

    count = [0 for i in range(N)]

    for i in range(N):
        count[A[i]] += 1

    M = N % 2

    res = 1

    if M == 1:
        if count[0] != 1:
            print(0)
            sys.exit()
        test = 0
        for i in range(1,N):
            if count[i] == test:
                res *= max(test,1)
                res %= mod
            else:
                res = 0
                break
            if test == 0:
                test = 2
            else:
                test = 0
    else:
        if count[0] != 0:
            print(0)
            sys.exit()
        test = 2
        for i in range(1,N):
            if count[i] == test:
                res *= max(test,1)
                res %= mod
            else:
                res = 0
                break
            if test == 0:
                test = 2
            else:
                test = 0

    print(res)



main()

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

from collections import Counter
c = Counter(A)

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

Solution (Python):
def check():
    if N %2 == 1:
        if A.pop(0) != 0:
            return 0
        pair = 2
    else:
        pair = 1
    
    for i in range(N//2):
        if A[2*i] == pair and A[2*i+1] == pair:
            pair += 2
        else:
            return 0
    return 1

N = int(input())
A = list(map(int, input().split()))
A.sort()
mod = int(1e9 +7)
if check() == 0:
    print(0)
else:
    print(pow(2, N//2, mod))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=1
mod=10**9+7
if N%2==0:
    for k in range(N//2):
        if A[2*k]==2*k+1 and A[2*k+1]==2*k+1:
            ans=ans*2%mod
            continue
        else:
            ans=0
            break
if N%2==1:
    if A[0]==0:
        ans=2
        for k in range(N//2-1):
            if A[2*k+2]==2*k+2 and A[2*k+1]==2*k+2:
                ans=ans*2%mod
                continue
            else:
                ans=0
                break
    else:
        ans=0
if N==1:
    if A[0]==0:
        ans=1
    else:
        ans=0
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
comb = 0
c = Counter(a)
if n%2==0:
    i = 1 
else:
    if c[0]!=1:
        print(0)
        exit()
    c.pop(0)
    i = 2

for k in sorted(c):
    if i==k and c[k]==2:
        i+=2
        comb += 1
    else:
        print(0)
        exit()

print(2**comb%(10**9+7))

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

mod = 10**9 + 7

lis = [abs(n-2*i-1) for i in range(n)]

a.sort()
lis.sort()

print(pow(2, n//2, mod)) if a==lis else print(0)

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

mod = 10**9 + 7

lis = [0] * n

for i in a: lis[i] += 1

for i in range(1,n):
	if lis[i] % 2 == 1:
		print(0)
		exit()
		
print(pow(2, n//2, mod))

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
s = 0
b = 0
d = [0]*n
if n % 2 == 0:
    for i in a:
        d[i] += 1 
    for i in range(1,n,2):
        if d[i] != 2:
            s = 1
            break
        else:
            b += 1
    ans = 2 ** b % (10**9 + 7)
else:
    for i in a:
        d[i] += 1 
    
    for i in range(0,n,2):
        if i == 0 and d[0] == 1:
            ans = 1
        elif d[i] != 2:
            s = 1
            break
        else:
            b += 1
    ans = 2 ** (b) % (10**9 + 7)

if s == 0:
    print(ans)
elif s == 1:
    print('0')

Solution (Python):
from math import ceil

N = int(input())
A = [int(i) for i in input().split()]
n = [0]*N
for a in A:
    n[a] += 1

if N&1:
    t = 0
    for a in range(len(n)):
        if a == 0:
            if n[a] != 1:
                print(0)
                break
        elif a&1:
            if n[a] != 0:
                print(0)
                break
        else:
            if n[a] != 2:
                print(0)
                break
            else:
                t += 1
    else:
        print(2**t%(10**9+7))
else:
    t = 0
    for a in range(len(n)):
        if a&1:
            if n[a] != 2:
                print(0)
                break
            else:
                t += 1
        else:
            if n[a] != 0:
                print(0)
                break
    else:
        print(2**t%(10**9+7))

Solution (Python):
from collections import Counter

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

if N % 2:
    if A == Counter((i + 1) // 2 * 2 for i in range(N)):
        print(pow(2, (N - 1) // 2, MOD))
    else:
        print(0)
else:
    if A == Counter(i // 2 * 2 + 1 for i in range(N)):
        print(pow(2, N // 2, MOD))
    else:
        print(0)

Solution (Python):
n=int(input())
l=sorted(map(int,input().split()))[::-1]
def f(x):
  t=n+1
  for i in l[x::2]:
    if t-2!=i: return 0
    t=i
  return 1
print(pow(2,n//2,10**9+7)*f(0)*f(1))

Solution (Python):
from collections import Counter

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

c = Counter(a)
r = 1 if n % 2 == 0 else 0
for k, v in c.items():
    if r == 0 and k == 0 and v == 1:
        continue
    if k != 0 and k % 2 == r and v == 2:
        continue
    print(0)
    break
else:
    print(2**(n//2) % (10**9+7))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def ok(n,aa):
        if n&1:
            if aa[0]!=0:return False
            b=2
            first=True
            for a in aa[1:]:
                if a!=b:return False
                if first:first=False
                else:
                    b+=2
                    first=True
        else:
            b=1
            first=True
            for a in aa:
                if a!=b:return False
                if first:first=False
                else:
                    b+=2
                    first=True
        return True

    md=10**9+7
    n=II()
    aa=LI()
    aa.sort()
    if ok(n,aa):print(pow(2,n//2,md))
    else:print(0)

main()

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

mod = 10**9+7
ans = 1

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            if a[i] != i + 1:
                ans = 0
        else:
            if a[i] != i:
                ans = 0
else:
    for i in range(n):
        if i % 2 == 0:
            if a[i] != i:
                ans = 0
        else:
            if a[i] != i + 1:
                ans = 0

for i in range(n//2):
    ans *= 2
    ans %= mod

print(ans)

Solution (Python):
import math
n=input()
mod = int(1e9) + 7
a=list(map(int,raw_input().split()))
if(len(a)%2==0 and a.count(0)>0):
    print(0)
elif(len(a)%2!=0 and a.count(0)>1):
    print(0)
else:    
    l=[0]*n
    b=set(a)
    for i in a:
        l[i] +=1
    for i in range(1,len(a)):
        if(l[i]%2==1):
            print(0)
            exit()
    if(a.count(0)):
        print(pow(2,len(b)-1,mod))
    else:
        print(pow(2,len(b),mod))

Solution (Python):



N = int(input())
A_list = list(map(int, input().split()))
sorted_A_list = sorted(A_list)


EXPECTED_LIST = []
is_N_even = (N % 2 == 0)
for n in range(N):
    is_n_even = (n % 2 == 0)
    if is_N_even:
        
        if is_n_even:
            EXPECTED_LIST.append(n+1)
        else:
            EXPECTED_LIST.append(n)
    else:
        
        if is_n_even:
            EXPECTED_LIST.append(n)
        else:
            EXPECTED_LIST.append(n+1)


if sorted_A_list == EXPECTED_LIST:
    
    print(2**(N//2) % (pow(10, 9)+7))
else:
    
    print(0)

Solution (Python):
mod = int(1e9) + 7
n = int(input())
a = list(map(int, input().split()))
lis = [0] * n
for i in a:
    lis[i] += 1
for i in range(1,n):
    if lis[i] % 2 == 1:
        print(0)
        exit()

print(pow(2, n//2, mod))

Solution (Python):
from collections import Counter

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

A_=Counter(A)
A_=A_.most_common()

flag=N%2

for a in A_:
    if a[0]%2==flag:
        print(0)
        exit()
    elif a[0]==0 and a[1]!=1:
        print(0)
        exit()
    elif a[0]!=0 and a[1]!=2:
        print(0)
        exit()

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
dic = {}
mod = 10**9+7

if n%2==0:
    for i in a:
        if i%2==0:
            print(0)
            exit()
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1

    for k, v in dic.items():
        if v != 2:
            print(0)
            exit()
    print(2**(n//2)%mod)

else:
    for i in a:
        if i%2==1:
            print(0)
            exit()
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1

    for k, v in dic.items():
        if v != 2 and k != 0:
            print(0)
            exit()
    print(2**(n//2)%mod)

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

Solution (Python):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
mod = 10**9 + 7
if n % 2 == 0:
    for i in a:
        if i % 2 == 0:
            print(0)
            exit()
    for i in c.values():
        if i != 2:
            print(0)
            exit()
    print(pow(2,n//2,mod))
if n % 2 == 1:
    for i in a:
        if i % 2 == 1:
            print(0)
            exit()
    if c[0]  == 1:
        c[0] = 2
    else:
        print(0)
        exit()
    for i in c.values():
        if i != 2:
            print(0)
            exit()
    print(pow(2,n//2,mod))

Solution (Python):
i=input
n=int(i())
print([0,pow(2,n//2,10**9+7)][sorted(map(int,i().split()))==[j+(j+n+1)%2for j in range(n)]])

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

Solution (Python):
i=input
n=int(i())
print([0,pow(2,n//2,10**9+7)][sorted(i().split(),key=int)==[str((j+n%2)//2*2+1-n%2)for j in range(n)]])

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

Solution (Python):
n = int(input())
l = sorted(list(map(int, input().split())))

if n == 1 and l ==[0, 0]:
    print(1)
    exit()
else:
    a = []
    for i in range(1, n):
        if n % 2 == 1: 
            if i < n and i % 2 == 0:
                a += [i] * 2
        else:
            if i < n and i % 2 == 1:
                a += [i] * 2
    else:
        if n % 2 == 1:
            a.insert(0, 0)
    
if l != a:
    print(0)
else:
    print((2 ** (n // 2)) % (10**9 + 7))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
C = [0]*N
a=0
def line(A,N):
    for i in range(N):
        C[A[i]] += 1
    if C[0] == 1:
        if N % 2==1:
            return pow(2,(N-1)//2)
        else:
            return 0
    for i in range(N):
        if C[i] != 2 and C[i]>=1:
            return 0
        elif C[i]==0:
            continue
    if N % 2 ==0:
        return pow(2,N//2)
    else:
        return pow(2,(N-1)//2)
a=line(A,N)
print(a%(pow(10,9)+7))

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

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

from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

ans = -1
A_ = Counter(A)
cnt = 0
if N % 2 == 1:
    if A_[0] != 1:
        ans = 0
    for i in range(2,N,2):
        if A_[i] != 2:
            ans = 0
            break
        cnt += 1
else:
    for i in range(1,N,2):
        if A_[i] != 2:
            ans = 0
            break
        cnt += 1

if ans == 0:
    print(ans)
else:
    print(2**cnt%mod)

Solution (Python):
import collections

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

m = collections.Counter(a)




if n % 2 == 0:
    mm = {2*i+1: 2 for i in range(0, n//2)}
else:
    mm = {2*i: 2 for i in range(0, n//2 + 1)}
    mm[0] = 1


for i in m:
    if i not in mm or m[i] != mm[i]:
        print(0)
        exit()

for i in mm:
    if i not in m or mm[i] != mm[i]:
        print(0)
        exit()

r = 10**9 + 7
ans = 1
for _ in range(n//2):
    ans = (ans * 2) % r

print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 

N = INT()
A = LIST()
 
flag = True

 

dic = defaultdict(int)
for i in range(N):
    if not A[i] in dic:
        dic[A[i]] = 1
    else:
        dic[A[i]] += 1
s = sum(A)
 
 
if N % 2 == 1:
    for i in range(N):
        if i == 0:
            if dic[i] != 1:
                flag = False
        elif i % 2 == 0:
            if dic[i] != 2:
                flag = False
        else:
            if dic[i] != 0:
                flag = False
        
        
    if flag == False:
        print(0)
    else:
        if N == 1:
            print(1)
        else:
            print(2 ** ((N) // 2) % mod)
 
else:
    for i in range(N):
        if (i - 1) % 2 == 0:
            if dic[i] != 2:
                flag = False
        else:
            if dic[i] != 0:
                flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** (N//2) % mod)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


N = INT()
A = LIST()

dic = {}
for i in range(N):
    if not A[i] in dic:
        dic[A[i]] = 1
    else:
        dic[A[i]] += 1

if N % 2 == 0:
    
    
    for i in range(N//2):
        
        if N - 1 - 2 * i not in dic:
            
            
            print(0)
            
            break
        elif dic[N-1-2*i] != 2:
            print(0)
            break
        else:
            pass
    else:
        print(2 ** (N // 2) % mod)
else:
    if A.count(0) != 1:
        print(0)
        
    else:
        
        for i in range(N//2):
            
            if N - 1 - 2 * i not in dic:
                print(0)
                break
            elif dic[N-1-2*i] != 2:
                print(0)
                break
            else:
                pass
        else:
            print(2 ** (N // 2) % mod)



exit()


flag = True
if N % 2 == 1:
    for i in range((N+1) // 2):
        if i == 0:
            if A.count(i) != 1:
                flag = False
        elif A.count(i * 2) != 2:
            flag = False
    if flag == False:
        print(0)
        exit()
    else:
        print(2 ** ((N-1) // 2))
else:
    for i in range(N // 2):
        if A.count(2 * i + 1) != 2:
            flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** (N//2))

Solution (Python):
n = int(input())
MOD = 10 ** 9 + 7

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

if n % 2 == 1:
    for i in range(n):
        if i % 2 == 1 and a[i] - 1 == i: continue
        elif i % 2 == 0 and a[i] == i: continue
        else: 
            print(0)
            exit()
else:
    for i in range(n):
        if i % 2 == 1 and a[i] == i: continue
        elif i % 2 == 0 and a[i] - 1 == i: continue
        else: 
            print(0)
            exit()

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

Solution (Python):
n = int(input())
MOD = 10 ** 9 + 7

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

if n % 2 == 1:
    l = (n + 1) * (n - 1)
else:
    l = n ** 2

if sum(a) == l // 2:
    print(2 ** (n//2) % MOD)
else:
    print(0)

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
if n % 2 == 0:
    l = n ** 2
else:
    l = (n - 1) * (n + 1)
if sum(A) == l // 2:
    print(2 ** (n // 2) % (10 ** 9 + 7))
else:
    print(0)

Solution (Python):
def resolve():
    n = int(input())
    MOD = 10**9+7
    S = list(map(int, input().split()))

    if n % 2 == 0:
        sn = (1 + (n-1)) * (n // 2)
    else:
        sn = (2 + (n-1)) * (n//2)

    ss = sum(S)

    print((2**(n//2))%MOD if ss == sn else 0)

if __name__ == '__main__':
    resolve()