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()))
ctr = Counter(A)
MOD = 10**9+7

if all(a%2 for a in A):
    for i in range(1,N,2):
        if ctr[i] != 2:
            print(0)
            exit()
    else:
        print(pow(2,N//2,MOD))
elif all(a%2==0 for a in A):
    if ctr[0] != 1:
        print(0)
        exit()
    for i in range(2,N,2):
        if ctr[i] != 2:
            print(0)
            exit()
    else:
        print(pow(2,N//2,MOD))
else:
    print(0)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    
    if(n % 2 == 0):
        for i in range(n-1):
            if i % 2 == 0 and a[i] != a[i+1] or i % 2 == 1 and a[i]+2 != a[i+1]:
                print(0)
                exit(0)
        print(2**(n//2) % (10**9+7))
        exit(0)
    if a[0] != 0:
        print(0)
        exit(0)
    for i in range(1, n-1):
        if i % 2 == 0 and a[i]+2 != a[i+1] or i % 2 == 1 and a[i] != a[i+1]:
            print(0)
            exit(0)
    print(2**((n-1)//2) % (10**9+7))
    exit(0)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    n = int(input())
    a = list(map(int, input().split(' ')))
    if n%2 == 1:
        a.append(0)
    a.sort()
    for i in range(n-1):
        if i%2 == 0:
            if a[i] == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
        else:
            if a[i]+2 == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
    result = 2 ** (n//2)
    print(result % (10**9+7))
if __name__ == '__main__':
    main()

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

a.sort()
if n%2 == 0:
    for i in range(n-1):
        if i%2 == 0:
            if a[i] == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
        else:
            if a[i]+2 == a[i+1]:
                continue
            else:
                print(0)
                sys.exit()
    result = 2 ** (n//2)
    print(result % (10**9+7))
else:
    if a[0] == 0:
        for i in range(1, n-1):
            if i%2 == 1:
                if a[i] == a[i+1]:
                    continue
                else:
                    print(0)
                    sys.exit()
            else:
                if a[i]+2 == a[i+1]:
                    continue
                else:
                    print(0)
                    sys.exit()
        result = 2**((n-1)//2)
        print(result %(10**9+7))
    else:
        print(0)
        sys.exit()

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

A.sort()

if(N%2==0):
    for i in range(N//2):
        if((A[i*2]!=(1+i*2))|(A[2*i+1]!=(1+i*2))):
            print(0)
            exit()
    print((2**(N//2)) % int(1e9+7))

else:
    if(A[0]!=0):
            print(0)
            exit()
    for i in range(N//2):
        if((A[i*2+1]!=((i+1)*2))|(A[i*2+2]!=((i+1)*2))):
            print(0)
            exit()
    print((2**(N//2)) % int(1e9+7))

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
start = 1 if N % 2 == 0 else 0
if N % 2 == 0:
    if counter[start] != 2:
        print(0)
        exit()
else:
    if counter[start] != 1:
        print(0)
        exit()

for i in range(start+2, N, 2):
    if counter[i] != 2:
        print(0)
        exit()
print(2 ** (N // 2) % (10**9 + 7))

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

Solution (Python):
def main():
  mod=1000000007
  n=int(input())
  a=sorted(list(map(int,input().split())))
  if n%2==0:
    if a==[x//2*2+1 for x in range(n)]:
      print(2**(n//2)%mod)
      return
  else:
    if a==[0]+[x//2*2+2 for x in range(n-1)]:
      print(2**(n//2)%mod)
      return
  print(0)

main()

Solution (Python):
import collections

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

A=collections.Counter(A_data)

if N%2==1:
    if not A[0]==1:
        print(0)
        exit()
    else:
        for i in range(2,N,2):
            if not A[i]==2:
                print(0)
                exit()

elif N%2==0:
    for i in range(1,N,2):
        if not A[i]==2:
            print(0)
            exit()

print(2**(N//2)%mod)

Solution (Python):
import collections

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

A=collections.Counter(A_data)

f=True
if N%2==1:
    if not A[0]==1:
        ans=0
    else:
        for i in range(2,N,2):
            if not A[i]==2:
                ans=0
                f=False
                break
        if f==True:
            ans=2**((N-1)//2)%mod
elif N%2==0:
    for i in range(1,N,2):
        if not A[i]==2:
            ans=0
            f=False
            break
    if f==True:
        ans=2**(N//2)%mod

print(ans)

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

table = collections.defaultdict(int)

for x in A:
    table[x] += 1

for x in table:
    if x != 0 and table[x] != 2:
        print(0)
        exit(0)

    elif N % 2 == 1:
        if x == 0 and table[x] != 1:
            print(0)
            exit(0)

    else:
        if x == 0:
            print(0)
            exit(0)

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

Solution (Python):
import sys
from collections import Counter
N = int(input())
A = [int(_) for _ in input().split()]

counter = Counter(A)

if N % 2 == 0:
    for n in range(1, N, 2):
        if counter[n] == 2:
            continue
        else:
            print(0)
            sys.exit()

elif N % 2 == 1:
    if counter[0] == 1:
        for n in range(2, N, 2):
            if counter[n] == 2:
                continue
            else:
                print(0)
                sys.exit()
    else:
        print(0)
        sys.exit()
MOD = 10 ** 9 + 7
ans = 1
for n in range(N // 2):
    ans *= 2
    ans %= MOD

print(ans)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    if a[0] == 0:
        t = 2
        for i in range(2, n, 2):
            if a[i] != a[i-1] or a[i] != t:
                print(0)
                exit()
            t += 2
        print((2 ** ((len(a) - 1) // 2)) % (10 ** 9 + 7))
    else:
        t = 1
        for i in range(1, n, 2):
            if a[i] != a[i-1]:
                print(0)
                exit()
            t += 2
        print((2 ** (len(a) // 2)) % (10 ** 9 + 7))


if __name__ == '__main__':
    slove()

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

f=True
if N%2!=0:
	idx=1
	x=2
	if A[0]!=0:f=False
else:
	idx=0
	x=1

for i in range(N//2):
	if A[idx]!=x or A[idx+1]!=x:
		f=False
	idx+=2
	x+=2

if f:print(2**(N//2)%(10**9+7))
else:print(0)

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

L=[0]*N
for a in A:
  L[a]+=1


if N%2==1:
  if L[0]==1 and L[2::2]==[2]*(N//2):
    print(2**(N//2)%(10**9+7))
  else:
    print(0)
else:
  if L[1::2]==[2]*(N//2):
    print(2**(N//2)%(10**9+7))
  else:
    print(0)

Solution (Python):
import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
    if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
else:
    if np.all(L-np.arange(N)-np.array([1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
if flag:
    a=1
    for i in range(N//2):
        a = (a*2)%(10**9+7)
    print(a)

Solution (Python):
from collections import Counter

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

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

Solution (Python):
from collections import*;n,*a=map(int,open(0).read().split());r=1
for k,v in Counter(a).items():r*=(0,1,2)[(n%2==v==k+1<2)+(0<(n+k)%2==v-1)*2]
print(r%(10**9+7))

Solution (Python):
from collections import Counter
n,*a=map(int,open(0).read().split())
r=1
for k,v in Counter(a).items():
	if (n+k)%2 and v==2:
		r*=2
	elif n%2 and k==0 and v==1:
		pass
	else:
		r=0
		break
print(r%(10**9+7))

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
tru = 0
acount = Counter(a)
if n == 1:
         if acount[0] == 1 :
                  print(1)
         else:
                  print(0)
elif n % 2 == 1:
         for i in range (1,n//2+1):
                  if acount[i*2] != 2:
                           print(0)
                           exit()
         else:
                  if acount[0] != 1:
                           print(0)
                           exit()
                  else:
                           print((2 ** (n//2) ) % (10 ** 9 + 7))
else:
         for j in range(1,n//2+1):
                  if acount[j*2-1] != 2:
                           print(0)
                           exit()
         else:
                  print((2 ** (n//2) ) % (10 ** 9 + 7))

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

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

S = []
if N % 2 == 0:
    for i in range(N//2):
        S.extend([2*i+1] * 2)
else:
    S.append(0)
    for i in range(N//2):
        S.extend([2*i+2] * 2)

if A != S:
    print(0)
    exit()

print((2 ** (N//2)) % INF)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    cnt = 0
    if n % 2 == 0:
        m = 1
        for i in range(1, n, 2):
            if not a[i] == a[i - 1] == m:
                print(0)
                exit()
            m += 2
            cnt += 1
    else:
        m = 0
        for i in range(0, n, 2):
            if i == 0:
                if not a[i] == m:
                    print(0)
                    exit()
            else:
                if not a[i] == a[i-1] == m:
                    print(0)
                    exit()
                cnt += 1
            m += 2
    print((2 ** cnt) % (10 ** 9 + 7))


if __name__ == '__main__':
    slove()

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

Solution (Python):
import collections

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

Solution (Python):
import sys

MOD = 1000000007

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

if(N%2 == 0):
    a.sort()
    for i in range(N//2):
        n = 2*i + 1
        if(a[2*i] != n or a[2*i + 1] != n):
            print(0)
            sys.exit()
    print((2 ** (N//2)) % MOD)
else:
    a.sort()
    if(a.count(0) != 1):
        print(0)
        sys.exit()
    for i in range((N-1)//2):
        n = 2*i + 2
        if(a[2*i + 1] != n or a[2*i + 2] != n):
            print(0)
            sys.exit()
    print((2 ** ((N-1)//2)) % MOD)

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

def main():
    N = int(input())
    a = sorted(list(map(int, input().split())), reverse=True)
    MOD = int(1e9) + 7
    ok = True
    ans = 1
    for i in range(N):
        
        if a[i] != N - 1 - 2 * (i//2):
            ok = False
            break
        elif i&1 == 1:
            ans *= 2
            ans %= MOD
    if not ok:
        print(0)
    else:
        print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
MOD = int(1e9+7)
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
    B = [0] * N
    for i in range(N // 2):
        B[2*i] = 2*i+1
        B[2*i+1] = 2*i+1
    if sorted(A) != B:
        print(0)
    else:
        ans = 1
        for i in range(N // 2):
            ans = ans * 2 % MOD
        print(ans)
else:
    B = [0] * N
    for i in range((N-1) // 2):
        B[2 * i + 1] = 2 * i + 2
        B[2 * i + 2] = 2 * i + 2
    if sorted(A) != B:
        print(0)
    else:
        ans = 1
        for i in range((N-1) // 2):
            ans = ans * 2 % MOD
        print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
check = 0

if N%2 == 1:
    for i in range(N):
        if A[i] == ((i+1)//2) * 2:
            pass
        else:
            check = 1
else:
    for i in range(N):
        if A[i] == (i//2) * 2 + 1:
            pass
        else:
            check = 1

if check == 0:
    ans = 1
    for i in range(N//2):
        ans *= 2
        ans %= 1000000007
else:
    ans = 0

print(ans)

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

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

def is_valid(A):
    counts = {}
    for a in A:
        if a in counts:
            counts[a] += 1
        else:
            counts[a] = 1
    if len(A) % 2 == 1:
        if counts[0] != 1:
            return False
        
        for i in range(1, len(A) // 2 + 1):
            if 2 * i not in counts or counts[2 * i] != 2:
                return False
        return True
    else:
        for i in range(1, len(A) // 2 + 1):
            if 2 * i - 1 not in counts or counts[2 * i - 1] != 2:
                return False
        return True
    return True
        
if is_valid(A):
    print(2 ** (N // 2) % 1000000007)
else:
    print(0)

Solution (Python):


from collections import Counter

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

c=Counter(a)

if c.most_common(1)[0][1]>2 or c[0]>1:
    print(0)
    exit()

for k,v in c.items():
    if k!=0 and v!=2:
        print(0)
        exit()
    if n%2==k%2:
        print(0)
        exit()
        
print(2**(n//2)%(10**9+7))

Solution (Python):
import collections
import math

mod = int(1e9 + 7)
n = int(input())
a = list(map(int,input().split()))

c = collections.Counter(a)
if n%2 == 0:
    check = True
    for i in range(n//2):
        if c[1+2*i] != 2:
            check = False
    if check:
        print(pow(2,n//2,mod))
    else:
        print(0)
else:
    if c[0] == 1:
        check = True
    else:
        check = False
    for i in range(1,n//2+1):
        if c[2*i] != 2:
            check = False
    if check:
        print(pow(2,n//2,mod))
    else:
        print(0)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
k = [0] * N
j = (N-1) % 2
for a in A:
    if a % 2 != j:
        print(0)
        break
    elif a == 0 and k[0] == 1:
        print(0)
        break
    elif k[a] == 2:
        print(0)
        break
    else:
        k[a] += 1
else:
    ans = 1
    i = 0
    while(i<(N-1)//2+j):
        ans *= 2
        ans %= 10**9+7
        i += 1
    print(ans)

Solution (Python):


import sys

n=int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

a=[]
for i in range(0,(n+1)//2):
	a.append(0)
for i in range(0,n):
	a[hoge[i]//2]+=1

if(a[0]%2!=n%2):
	print(0)
else:
	for i in range(1,(n+1)//2):
		if(a[i]!=2):
			print(0)
			sys.exit()
	print((max(a[0],1)*pow(2,(n-1)//2))%1000000007)

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

Solution (Python):
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
A.sort()
for i, a in enumerate(A):
    if N % 2 == 1:
        try:
            assert a == (i + 1) // 2 * 2
        except AssertionError:
            print(0)
            exit()
    else:
        try:
            assert a == i // 2 * 2 + 1
        except AssertionError:
            print(0)
            exit()
ans = pow(2, N // 2, 10 ** 9 + 7)
print(ans)

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

mod=10**9+7
A=sorted(A)
possible=1
if N%2==1:
    if A[0]!=0:
        possible=0
    for i in range(1,N):
        if A[i]!=i+i%2:
            possible=0
            break
    if possible==1:
        ans=2**((N-1)//2)%mod
    else:
        ans=0
else:
    for i in range(N):
        if A[i]!=i+(i+1)%2:
            possible=0
            break
    if possible==1:
        ans=2**(N//2)%mod
    else:
        ans=0
print(ans)

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

Solution (Python):
from collections import Counter
def solve():
    if N % 2 == 1:
        if counter[0] != 1:
            return 0
        else:
            for i in range(2, N, 2):
                if counter[i] != 2:
                    return 0
            return (2 ** (N // 2)) % mod
    else:
        for i in range(1, N, 2):
            if counter[i] != 2:
                return 0
        return (2 ** (N // 2)) % mod

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
dic = {}
for a in A:
    if a in dic:
        dic[a] += 1
        if N % 2 == 1 and a == 0:
            print(0)
            exit()
        elif dic[a] > 2:
            print(0)
            exit()
    else:
        dic[a] = 1
        if N % 2 == 1:
            if a % 2 == 1 or a >= N:
                print(0)
                exit()
        elif N % 2 == 0:
            if a % 2 == 0 or a >= N:
                print(0)
                exit()

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

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

if A == B:
    print(2 ** ( N // 2) % mod)
else:
    print(0)

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

Solution (Python):
import sys
n=int(input())
A=sorted(list(map(int,input().split())))
ans=1
mod=1000000007
if n%2==1:
    if A[0]==0:
        for i in range(1,n//2+1):
            if A[i*2-1]==A[i*2]==i*2:
                ans*=2
                ans%=mod
            else:
                print(0)
                sys.exit()
    else:
        print(0)
        sys.exit()
else:
    for i in range(n//2):
        if A[i*2]==A[i*2+1]==i*2+1:
            ans*=2
            ans%=mod
        else:
            print(0)
            sys.exit()

print(ans)

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse = True)

valid = True
t = n-1
for i in range(n):
	if arr[i] != t :
		valid = False
	if i % 2 == 1 :
		t -= 2 

if not valid:
	print(0)
else:
	print(2 ** (n//2) % (10 ** 9 + 7))

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


if n%2==0:
    for i in range(n):
        d[a[i]]+=1
    if all(int(x)==2 for x in d.values()):
        print((2**(n//2))%(10**9+7))
        exit()
    else:
        print(0)
        exit()

else:
    d["0"]+=1
    for i in range(n):
        d[a[i]]+=1
    if all(int(x)==2 for x in d.values()):
        print((2**((n-1)//2))%(10**9+7))
        exit()
    else:
        print(0)
        exit()

Solution (Python):
n = int(input())
dp = [2]*n
dp[0] = 1
mod = 10**9+7
an = [int(i) for i in input().split()]

if n % 2 == 1:
  for i in an:
    if i % 2 == 1 or dp[i] == 0:
      print(0)
      exit()
    else:
      dp[i] -= 1
  print(2**((n-1)//2)%mod)
else:
  for i in an:
    if i % 2 == 0 or dp[i] == 0:
      print(0)
      exit()
    else:
      dp[i] -= 1
  print(2**(n//2)%mod)

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

print(ans)

Solution (Python):

from collections import Counter


def main():
    n = int(input())
    a = sorted(Counter(map(int, input().rstrip().split())).items())
    MOD = 10 ** 9 + 7
    if n % 2 == 1 and a[0][1] != 1:
        print(0)
    elif not all(i[1] == 2 for i in a[1:]):
        print(0)
    else:
        if n % 2 == 0:
            print(2 ** len(a) % MOD)
        else:
            print(2 ** (len(a) - 1) % MOD)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7
c = 1-N%2
flag = True
di = {}
if(N==1):
    if(A[0]==0):
        print(1)
    else:
        print(0)
else:
    for i in A:
        if(i not in di):
            di[i]=1
        else:
            di[i]+=1
    for i in range(N//2):
        if(i+c==0):
            if(0 not in di):
                flag = False
            else:
                flag &= (di[i]==1)
        else:
            if(i*2+c not in di):
                flag = False
            else:
                flag &= (di[i*2+c]==2)
        if(not flag):
            print(0)
            break
    else:
        print((2<<(N//2-1))%mod)

Solution (Python):
from collections import Counter

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

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

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

Solution (Python):











import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
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()
    c = Counter(A)
    if N % 2 != 0 and c[0] != 1:
        print(0)
        exit()
        
    for i in range(1,(N + 1) // 2):
        if c[i*2-(N%2==0)] != 2:
            print(0)
            exit()
    print(pow(2,N//2,mod))
if __name__ == '__main__':
    main()

Solution (Python):











import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
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()
    c = Counter(A)
    if N % 2 != 0 and c[0] != 1:
        print(0)
        exit()
        
    for i in range(1,(N + 1) // 2):
        if c[i*2-(N%2==0)] != 2:
            print(0)
            exit()
    print(pow(2,N//2,mod))
if __name__ == '__main__':
    main()

Solution (Python):











import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
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()
    c = Counter(A)
    if N % 2 != 0 and c[0] != 1:
        print(0)
        exit()
        
    for i in range(1,(N + 1) // 2):
        if c[i*2-(N%2==0)] != 2:
            print(0)
            exit()
    print(pow(2,N//2,mod))
if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]

import collections
c=collections.Counter(a)
l=len(c)
ans=1

for i in range((n-1)%2,n,2):
    if i==0:
        if c[0]!=1:
            ans=0
    elif c[i]==2:
        ans*=2
    else:
        ans=0
    ans=ans%(10**9+7)


print(ans)

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

def check():
    if N % 2 == 0:
        for i in range(1,N)[::2]:
            if A[i-1] != i or A[i] != i:    return 0
        return int(2**(N//2)) % int(1e9+7)
    else:
        if A[0] != 0:   return 0
        else:
            for i in range(2,N)[::2]:
                if A[i-1] != i or A[i] != i:    return 0
            return int(2**((N-1)//2)) % int(1e9+7)
        
print(check())

Solution (Python):
"""
自分の左に並んでいた人数と自分の右に並んでいた人数の差の絶対値はAi
元の並び方が何通りあるか

N = 3
並び    1 2 3
As      2 0 2

N = 4
並び    1 2 3 4
As      3 1 1 3

2^n通りだろう
"""
N = int(input())
As = list(map(int,input().split()))
As = sorted(As)
mod = 10**9 + 7

if N % 2 == 0:
    A = [(i)//2*2+1 for i in range(N)]
    if As == A:
        print(2**(N//2)%mod)
    else:
        print(0)
else:
    A = [0] + [(i+1)//2*2 for i in range(1,N)]
    if As == A:
        print(2**((N-1)//2)%mod)
    else:
        print(0)

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

A.sort()
B = [abs(a-b) for a,b in zip(range(N-1,-1,-1),range(N))]
B.sort()

if A==B:
    print(pow(2,N//2,10**9+7))
else:
    print(0)

Solution (Python):
from collections import Counter

def main():
    N = int(input())
    A = list(map(int,input().split()))
    for a in A:
        if (a + N + 1)%2:
            return 0
    for k,v in Counter(A).items():
        if k == 0 and v != 1:
            return 0
        if k != 0 and v != 2:
            return 0
    ans = 1
    mod = 10**9 + 7
    for i in range(N//2):
        ans *= 2
        ans %= mod
    return ans

print(main())

Solution (Python):
import sys
from sys import stdin

mod = 1000000007

n = int(input())


a = [int(x) for x in input().split()]

a = sorted(a)
predict = [n - (((n - i + 1) // 2) * 2) + 1 for i in range(0, n)]
if a != predict:
    print(0)
    sys.exit()
print(pow(2, (n // 2), mod))