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):
from collections import Counter


N = int(input())
A = list(map(int, input().split()))
c = sorted(Counter(A).items())

MOD = 10**9 + 7

if N%2 == 0:
    for i in range(len(c)):
        if c[i][0] != 2*i+1 or c[i][1] != 2:
            print(0)
            exit()
    print(pow(2, len(c), MOD))
else:
    if c[0][0] != 0 or c[0][1] != 1:
        print(0)
        exit()
    for i in range(1, len(c)):
        if c[i][0] != 2*i or c[i][1] != 2:
            print(0)
            exit()
    print(pow(2, len(c)-1, 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):
def assert_(L, nm):
    for i in range(len(L) // 2):
        i *= 2
        if L[i] == L[i + 1] == nm:
            nm += 2
            continue
        print(0)
        exit()
    pass


mod = int(1e9) + 7

n = int(input())
A = [int(x) for x in input().split()]
A.sort()

if n % 2 == 0:
    if A[0] != 1 or A[1] != 1:
        print(0)
        exit()
    assert_(A[2:], 3)
else:
    if A[0] != 0:
        print(0)
        exit()
    assert_(A[1:], 2)

ans = 1
num_power = (n - 1) // 2 if n % 2 == 1 else n // 2
for _ in range(num_power):
    ans *= 2
    ans %= mod
print(ans)

Solution (Python):

from collections import Counter, deque 












import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=list(map(int,input().split()))
    mod=10**9+7
    if N%2==0:
        l=[2*i+1 for i in range(0,N//2)]+[2*i+1 for i in range(0,N//2)]
        if Counter(l)!=Counter(A):
            ans=0
        else:
            ans=2**(N//2)
    else:
        l=[2*i for i in range(1,N//2+1)]*2+[0]
        if Counter(l)!=Counter(A):
            ans=0
        else:
            ans=2**(N//2)
    print(ans%mod)


resolve()

Solution (Python):

n = int(input())
a = sorted(list(map(int, input().split())))
b = [0 for _ in range(n)]

if n % 2:
    for i in range(1,n,2):
        b[i] = b[i+1] = n - i
else:
    for i in range(0,n,2):
        b[i] = b[i+1] = n - (i + 1)
b.sort()

for i, j in zip(a, b):
    if i != j:
        print(0)
        exit()

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

Solution (Python):
def resolve():
    N = int(input())
    arr = tuple(map(int, input().split()))
    from collections import Counter
    cnt = Counter(arr)
    m = 10 ** 9 + 7
    ans = 1
    for i in range(N - 1, 0, -2):
        if i not in cnt or cnt[i] != 2:
            ans = 0
            break
        ans = (ans << 1) % m
    if N % 2 and (0 not in cnt or cnt[0] != 1):
        ans = 0
    print(ans % m)

resolve()

Solution (Python):
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
if n % 2 == 1 and c[0] == 1 and all(c[2 * i] == 2 for i in range(1, n // 2 + 1)):
  print(2 ** (n // 2) % (10 ** 9 + 7))
elif n % 2 == 0 and all(c[2 * i - 1] == 2 for i in range(1, n // 2 + 1)):
  print(2 ** (n // 2) % (10 ** 9 + 7))
else:
  print(0)

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


def power_func(a, n, p):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % p
        a = a * a % p
        n = n >> 1
    return res

A.sort()
if N % 2 == 0 and A == [2*(i // 2)+1 for i in range(N)] or\
        N % 2 == 1 and A == [2*((i+1) // 2) for i in range(N)]:
    
    print(power_func(2,N//2,MOD))
else:
    print(0)

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


def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res


A.sort()
if N % 2 == 0 and A == [2*(i // 2)+1 for i in range(N)] or\
        N % 2 == 1 and A == [2*((i+1) // 2) for i in range(N)]:
    
    print(power_func(2,N//2,MOD))
else:
    print(0)

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


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
d=dict()
for i in range(n):
  if a[i] not in d:
    d[a[i]]=1
  else:
    d[a[i]]+=1
d=sorted(list(d.items()))
if n%2:
  for i in range(len(d)):
    if i==0:
      if d[i][0]!=0 or d[i][1]!=1:
        print(0)
        exit()
    else:
      if d[i][0]!=i*2 or d[i][1]!=2:
        print(0)
        exit()
  print(pow(2,len(d)-1,mod))
else:
  for i in range(len(d)):
    if d[i][0]!=2*i+1 or d[i][1]!=2:
      print(0)
      exit()
  print(pow(2,len(d),mod))

Solution (Python):
import collections

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

c = collections.Counter(A)

for value in c.values():
    if(value == c[0]):
        continue
    if(value%2 != 0):
        print(0)
        quit()

if(N%2 != 0):
    if(c[0] == 1):
        ans = (2**(len(c)-1))%mod    
        print(ans)
    else:
        print(0)
else:
    if(c[0]):
        print(0)
    else:
        ans = (2**len(c))%mod
        print(ans)

Solution (Python):
n=int(input())
mod=10**9+7
from collections import Counter as co
var=co(map(int,input().split()))
if n%2:
    if 0 not in var:print(0);exit()
    if var[0]!=1:print(0);exit()
    for i in range(2,n,2):
        if i not in var:print(0);exit()
        if var[i]!=2:print(0);exit()
else:
    for i in range(1,n,2):
        if i not in var:print(0);exit()
        if var[i]!=2:print(0);exit()
print(2**(n//2)%mod)

Solution (Python):

if False:
    S=list(input())
    N=len(S)
    ans=0
    for i in range(N):
        if S[i]=='U':
            ans+=N-(i+1)
            ans+=i*2
        else:
            ans+=(N-(i+1))*2
            ans+=i
    print(ans)
            

if False:
    N,M=map(int,input().split())
    ans=min(N,M//2)
    if N<(M//2):
        ans+=((M//2-N)*2+(M%2))//4
    print(ans)


if False:
    N,K=map(int,input().split())
    ans=3*(N-1)+6*(K-1)*(N-K)+1
    ans=ans/(N**3)
    print(ans)


if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ANS=[sum(A)-2*sum(A[1::2])]
    for i in range(N-1):
        ANS.append(2*A[i]-ANS[-1])
    print(*ANS)


N=int(input())
A=[int(i) for i in input().split()]
const=10**9+7
cnt={}
ans=0
flag=True
if N%2==0:
    for k in range(N):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(1,N,2):
        if cnt[k]!=2:
            flag=False
            break
    if flag: ans=pow(2,N//2,const)
else:
    for k in range(N):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(0,N,2):
        if k==0:
            if cnt[0]!=1:
                flag=False
                break
        else:
            if cnt[k]!=2:
                flag=False
                break
    if flag: ans=pow(2,(N-1)//2,const)
print(ans)

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

def naive_quad_power(n):
    ret = 1
    for i in range(n):
        ret = (2*ret)%mod
        
    return ret

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    valid = {abs(N-1-2*i):2 for i in range(N)}
    if N % 2 == 1:
        valid[0] = 1
        
    check = {k:0 for k in valid}
    val = True
    for a in A:
        if a in check and check[a] < valid[a]:
            check[a] = check[a]+1
        else:
            val = False
            break
    
    
    
    ret = naive_quad_power(N//2) if val else 0
    print(ret)
    
solve()

Solution (Python):
from collections import defaultdict


def my_pow(x,n):
    ret = 1
    mod = 10**9+7
    for _ in range(n):
        ret = (ret*x)%mod
    return ret
    

def check():
    N = int(input())
    A = [int(i) for i in input().split()]
    count = defaultdict(int)
    
    if N%2==0:
        for a in A:        
            if a%2==0:
                return 0
            count[a] += 1
        for cnt in count.values():
            if cnt != 2:
                return 0
        return my_pow(2,len(count))
    else:
        for a in A:
            if a%2!=0:
                return 0
            count[a] += 1
        if count[0] != 1:
            return 0
        count[0] = 2
        for cnt in count.values():
            if cnt != 2:
                return 0
        return my_pow(2,len(count)-1)
      
print(check())

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

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

Solution (Python):
def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

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

A.sort()
if N%2:
  correct = [0]
  for i in range(N//2):
    correct += [(i+1)*2]*2
else:
  correct = []
  for i in range(N//2):
    correct += [i*2+1]*2
    
if A == correct:
  print(power_func(2, N//2, MOD))
else:
  print(0)

Solution (Python):
n = int(input())
a = sorted(list(map(int, input().split())))
b = [0 for _ in range(n)]

if n % 2:
    for i in range(1,n,2):
        b[i] = b[i+1] = n - i
else:
    for i in range(0,n,2):
        b[i] = b[i+1] = n - (i + 1)
b.sort()

for i, j in zip(a, b):
    if i != j:
        print(0)
        exit()

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

Solution (Python):
from collections import Counter
mod = 10 ** 9 + 7
ans = 0
n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
flag = True
if n % 2 == 0:
    odd = 1
    for val, cnt in sorted(c.items()):
        
        if cnt == 2 and val == odd:
            odd += 2
        else:
            flag = False
            break
else:
    even = 0
    for val, cnt in sorted(c.items()):
        
        if val == 0 and cnt == 1:
            even += 2
            continue
        if val == even and cnt == 2:
            even += 2
            continue
        else:
            flag = False
            break
if flag:
    ans = pow(2, n // 2, mod)
else:
    ans = 0
print(ans)

Solution (Python):
from collections import Counter
n, *a = map(int, open(0).read().split())
a = Counter(a)

if n%2==0:
        i = cant = 0
        for v, c in sorted(a.items()):
                if 2*i+1!=v or c!=2: cant = True
                i += 1
else:
        i = cant = 0
        for v, c in sorted(a.items()):
                if i==0: cant = (c!=1)
                elif 2*i!=v or c!=2:  cant = True
                i += 1

if cant: print(0)
else: print(pow(2, n//2, 1000000007))

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

ans = 2**(N//2)
table = collections.defaultdict(int)
flag = True
for x in A:
    table[x] += 1

for x in table:
    if x % 2 == N % 2:
        flag = False
        break
    if x == 0 and table[x] > 1:
        flag = False
        break
    if x >= 1 and table[x] != 2:
        flag = False
        break
    if x > N - 1:
        flag = False
        break
mod = 10**9 + 7
if flag:
    print(ans % mod)
else:
    print(0)

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
ans = 1
cnt = [0] * N
for a in A:
    if a != 0 and cnt[a] == 1:
        ans = ans * 2 % mod
    elif a == 0 and cnt[a] != 0 or cnt[a] > 1:
        ans = 0
    cnt[a] += 1
print(ans)

Solution (Python):
from collections import defaultdict

MOD = 10 ** 9 + 7
N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)

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

for v, c in d.items():
    if N % 2 == 0:
        if v % 2 == 1 and c == 2:
            continue
        else:
            print(0)
            exit()
    else:
        if v % 2 == 0 and c == 2:
            continue
        elif v == 0 and c == 1:
            continue
        else:
            print(0)
            exit()

print(pow(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):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = sorted(inpl())
now = 0 if n%2 else -1
for i in range(n):
    if i%2 == n%2:
        now += 2
    if a[i] != now:
        print(0)
        quit()
print(pow(2,n//2)%mod)

Solution (Python):
from collections import Counter

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

if len(A) % 2 == 1:
    if cntA[0] != 1:
        print(0)
        exit()
    cnt = 1
    for i in range(2, N, 2):
        if cntA[i] != 2:
            print(0)
            exit()
        cnt += 2
    if cnt != N:
        print(0)
        exit()
else:
    cnt = 0
    for i in range(1, N, 2):
        if cntA[i] != 2:
            print(0)
            exit()
        cnt += 2
    if cnt != N:
        print(0)
        exit()

print(pow(2, N // 2, 10**9 + 7))

Solution (Python):
def main():
    MOD = 10**9 + 7
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    from collections import Counter
    c = Counter(A)
    if N % 2 == 1:
        if all(v == 2 if k != 0 else v == 1 for k, v in c.items()):
            ans += pow(2, (len(c.keys())-1), MOD)
    else:
        if all(v == 2 for k, v in c.items()):
            ans += pow(2, (len(c.keys())), MOD)
    k = sorted(set(A))
    for i in range(len(c.keys())-1):
        if k[i] + 2 != k[i+1]:
            ans = 0
            break
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    a.sort()
    if n&1:
        n >>= 1
        if a != sorted([2*i for i in range(n+1)]+[2*i for i in range(1,n+1)]):
            print(0)
        else:
            print(pow(2,n,mod))
    else:
        n >>= 1
        if a != sorted([2*i+1 for i in range(n)]+[2*i+1 for i in range(n)]):
            print(0)
        else:
            print(pow(2,n,mod))
    return


if __name__ == "__main__":
    solve()

Solution (Python):
import sys
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



N = ii()
A = sorted(li())

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

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

INF = 10**9+7
print(2**(N//2)%INF)

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, accumulate
import itertools
import heapq
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False



def main():
    N = I()
    A = LI()
    A = sorted(A)

    cur = 0
    value = 1
    if N % 2 == 1:
        cur = 1
        value = 2
        if A[0] != 0:
            print(0)
            return

    while cur < N:
        if not (A[cur] == value and A[cur+1] == value):
            print(0)
            return
        cur += 2
        value += 2

    if N % 2 == 1:
        print(pow(2, (N - 1) // 2, MOD))
    else:
        print(pow(2, N // 2, MOD))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
c = a.count(0)
    
odd_count = len(list(filter(lambda x: (x%2 != 0) , a)))

if(n%2 == 1):
    if(c != 1 or odd_count !=0):
        print(0)
        exit()
else:
    if(c != 0 or odd_count !=n):
        print(0)
        exit()
        
m = 1000000007
p = n//2
ans = 1
for _ in range(0,p):
    ans = 2*ans % m
print(ans)

Solution (Python):
n = int(input())
l = input().split(" ")
l1=[0]*n
for i in range(len(l)):
    l[i]=int(l[i])
    l1[l[i]]+=1
if l1[0]>0 and n%2==0:
    print(0)
elif l1[0]>1 and n%2==1:
    print(0)
else:
    c = set(l)
    mod = int(1e9) +7
    for k in range(1,len(l1)):
        if l1[k]%2!=0:
            print(0)
            exit()
    if(l1[0]):    
        print(pow(2,len(c)-1,mod))
    else:
        print(pow(2,len(c),mod))

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):
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):
def modpow(val, n, mod):
    ret = 1
    while n:
        if n & 1:
            ret = (ret * val) % mod
        val = (val * val) % mod
        n = n >> 1
    return ret

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

a_list.sort()

if n % 2 != 0:
    if a_list[0] != 0:
        print(0)
        exit()
    else:
        a_list = a_list[1:]

if n % 2 == 0:
    for i in range(len(a_list)):
        if a_list[i] != ((i // 2) + 1) * 2 - 1:
            print(0)                                                                                        
            exit() 
else:    
    for i in range(len(a_list)):
        if a_list[i] != ((i // 2) + 1) * 2:
            print(0)
            exit()

print(modpow(2, len(a_list) // 2, (10 ** 9) + 7))

Solution (Python):
from collections import Counter
MOD = 10**9 + 7
N = int(input())
A = list(map(int,input().split()))
C = Counter(A)
ans = 1
if N%2 == 1:
    if C[0] != 1:
        print(0)
        exit(0)
    else:
        for e in C:
            if e == 0:
                pass
            elif C[e] != 2:
                print(0)
                exit(0)
            else:
                ans *= 2
                ans %= MOD
else:
    for e in C:
        if C[e] != 2:
            print(0)
            exit(0)
        else:
            ans *= 2
            ans %= MOD

print(ans)

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

from collections import Counter
ca = Counter(a)
d = n % 2
if d == 1:
    z = ca.pop(0) if 0 in ca else 0
    if z != 1:
        print(0)
        exit()

for i in range(1 + d, n + d, 2):
    if ca[i] != 2:
        print(0)
        exit()

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

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

mod = 10**9+7

A = sorted(A)
is_possible = True
if N%2 == 0:
    for i in range(N/2):
        if A[2*i] != 2*i+1 or A[2*i+1] != 2*i+1:
            is_possible = False
else:
    for i in range(1, (N+1)/2):
        if A[2*i-1] != 2*i or A[2*i] != 2*i:
            is_possible = False

if is_possible:
    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()))
C = [0]*N
for a in A:
  C[a] += 1
isOk = True
if N % 2 == 0:
  if C[0] != 0:
    isOk = False
  i = 1
  while i < N:
    if C[i] != 2:
      isOk = False
    i += 2
  i = 2
  while i < N:
    if C[i] != 0:
      isOk = False
    i += 2
else:
  if C[0] != 1:
    isOk = False
  i = 1
  while i < N:
    if C[i] != 0:
      isOk = False
    i += 2
  i = 2
  while i < N:
    if C[i] != 2:
      isOk = False
    i += 2
if isOk:
  print((2**(N//2))%(10**9+7))
else:
  print(0)

Solution (Python):
from collections import Counter
N = int(input())
Alist = list(map(int, input().split()))
Ac = Counter(Alist)
mod = 10**9+7
if N%2==0:
    for i in range(1, N, 2):
        if Ac[i] != 2:
            print(0)
            break
    else:
        print(pow(2, (N//2), mod))
else:
    if Ac[0] != 1:
        print(0)
    else:
        for i in range(2, N, 2):
            if Ac[i] != 2:
                print(0)
                break
        else:
            print(pow(2, (N//2), mod))

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

x = n%2 + 1
for i in range(n)[n%2+2::2]:
    if a[i] != a[i+1] or a[i] - x != 2:
        print(0)
        exit()
    x = a[i]
    
print(2**(n//2) % (10**9+7))

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

if n%2:
    a = a[1:]

x = n%2 + 1
for i in range(len(a))[::2]:
    if a[i] != x:
        print(0)
        exit()
    x += 2

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

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

Solution (Python):
from collections import Counter
N = int(input())
AC = Counter(list(map(int, input().split())))
if N % 2 == 1:
    if N == 1:
        ans = AC[0] == 1
    else:
        ans = AC[0] == 1
        for k, v in AC.most_common(N//2):
            if k > N-1 or k % 2 != 0 or v != 2:
                ans = False
                break
else:
    ans = True
    for k, v in AC.most_common():
        if k > N or k % 2 == 0 or v != 2:
            ans = False
            break
if ans:
    print(pow(2, N//2, 10**9+7))
else:
    print(0)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    S = defaultdict(int)
    for a in A:
        S[a]+=1
        if S[a]>=3:
            print(0)
            return
    if S[0]>=2:
        print(0)
        return 
    print(pow(2,N//2,mod))

    

if __name__ == '__main__':
    main()

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

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

if n%2 == 1:
    m = (n+1)//2
    l =[0]*m
    for i in range(n):
        if (n-A[i]-1)%2 != 0:
            print(0)
            exit()
        else:
            id = (n-A[i]-1)//2
            l[id] += 1
    
    ans = 1
    for i in range(m):
        
        if i != m -1:
            if l[i] != 2:
                print(0)
                exit()
            else:
                ans *= l[i]
                ans %= mod
        else:
            if l[i] != 1:
                print(0)
                exit()
            else:
                ans *= l[i]
                ans %= mod
    print(ans)

else:
    m = n//2
    l =[0]*m
    for i in range(n):
        if (n-A[i]-1)%2 != 0:
            print(0)
            exit()
        else:
            id = (n-A[i]-1)//2
            l[id] += 1
    
    ans = 1
    for i in range(m):
        
        if l[i] != 2:
            print(0)
            exit()
        else:
            ans *= l[i]
            ans %= mod
    print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
num = [0] * N
ng = False
for i in range(N):
    num[A[i]] += 1
for i in range(1, N):
    if N % 2:
        if i % 2 and num[i]:
            ng = True
        elif i % 2 == 0 and num[i] != 2:
            ng = True
    else:
        if i % 2 == 0 and num[i]:
            ng = True
        elif i % 2 and num[i] != 2:
            ng = True
if N % 2 and A.count(0) != 1:
    ng = True
if N % 2 == 0 and A.count(0) > 0:
    ng = True
ans = pow(2, N // 2, 1000000007)
if ng:
    ans = 0
print(ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
if N%2==0:
	for i in range (N):
		if A[i]%2 != 1:
			print(0)
			exit()
	print((2**(N//2))%(10**9+7))
else:
	for i in range (N):
		if A[i]%2!=0:
			print(0)
			exit()
	if min(A)!=0 or A.count(0)!=1:
		print(0)
		exit()
	else:
		print((2**((N-1)//2))%(10**9+7))

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

MOD = 10**9+7

from collections import Counter
 
for key,count in sorted(Counter(A).items(), key=lambda x:x[0]):
    if key == 0 and N % 2 == 1:
        continue
    if count == 2 and key % 2 != N % 2:
        continue
    print(0)
    exit()
 

if N % 2 == 1:
    N -= 1
 
print(2 ** (N//2) % MOD)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
if n % 2 == 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()
else:
    for i in range(0, n, 2):
        if a[i] != a[i + 1] or a[i] != i + 1:
            print(0)
            exit()
print(2 ** (n // 2) % (10 ** 9 + 7))

Solution (Python):
def main():
    N=int(input())
    A=list(map(int,input().split()))
    t={}
    flag=True
    for i in range(N):
        if str(A[i]) not in t:
            t[str(A[i])]=1
        elif t[str(A[i])]==1:
            t[str(A[i])]=2
        elif t[str(A[i])]==2:
            flag=False
            break
    if flag==False:
        print(0)
    if flag and N%2==1:
        if t["0"]!=1:
            print(0)
            flag=False
        if flag:
            count_zero=0
            for v in t.values():
                if v==1:
                    count_zero+=1
                    if count_zero>=2:
                        print(0)
                        flag=False
                        break
        if flag:
            print((2**(N//2))%1000000007)

    elif flag and N%2==0:
        for v in t.values():
            if v==1:
                print(0)
                flag=False
                break
        if flag:
            print((2**(N//2))%1000000007)
    
if __name__=="__main__":
    main()