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 sys import stdin

mod = 1000000007

n = int(stdin.readline().rstrip())


a = [int(x) for x in stdin.readline().rstrip().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))

Solution (Python):
from sys import stdin


def resolve():
    n = int(stdin.readline().rstrip())
    
    
    a = [int(x) for x in stdin.readline().rstrip().split()]

    a = sorted(a)
    predict = [n - (((n - i + 1) // 2) * 2) + 1 for i in range(0, n)]
    if a != predict:
        return 0

    ret = 1
    for i in range(0, n // 2):
        ret = (ret * 2) % 1000000007
    return ret


print(resolve(), '\n')

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

Solution (Python):

"""
C - Lining Up
https://atcoder.jp/contests/arc066/tasks/arc066_a

"""
import sys

from collections import Counter

def solve(N, array):
    cnt = Counter(array)
    res = []
    for k, v in cnt.items():
        if k == 0 and v > 1:
            return 0
        if k != 0 and v != 2:
            return 0
        if N%2:
            if k%2:
                return 0
            res.append(v)
        else:
            if k%2 == 0:
                return 0
            res.append(v)
    ans = 1
    MOD = 10**9 + 7
    for r in res:
        ans = (ans * r) % MOD
    return ans


def main(args):
    N = int(input())
    array = [int(a) for a in input().split()]
    ans = solve(N, array)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

if l[0] != n%2:
    print(0)
    exit()

for i in l[1:]:
    if i!=0 and i!=2:
        print(0)
        exit()
print(2**(n//2)%m)

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
 
A.sort(reverse=True)
 
if N % 2 == 1:
    if A[-1] == 0:
        A.pop()
    else:
        print(0)
        quit()
 
for i in range(0, N - 2, 2):
    if A[i] != N - i - 1 or A[i] != A[i + 1]:
        print(0)
        quit()
 
print(2 ** (N // 2) % (10 ** 9 + 7))

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

A.sort(reverse=True)

if N % 2 == 1:
    if A[-1] == 0:
        A.pop()
    else:
        print(0)
        quit()

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

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

Solution (Python):
def A_validation(A, N):
    '''
    input
    A, N: abs_list, population
    output
    True/False: can you line up?
    '''
    A = sorted(A)
    num = N - 1
    
    if N % 2 == 0:
        while A:
            tmp1 = A.pop()
            tmp2 = A.pop()
            if tmp1 != tmp2 or tmp1 != num:
                return False
            num = num - 2
        return True
    
    else:
        if A.pop(0) != 0:
            return False
        while A:
            tmp1 = A.pop()
            tmp2 = A.pop()
            if tmp1 != tmp2 or tmp1 != num:
                return False
            num = num - 2
        return True

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

mod = 1000000007
if A_validation(A, N):
    ans = 2 ** (N // 2) % mod
else:
    ans = 0
print(ans)

Solution (Python):


from collections import Counter

def solve(N, A):
    flag = False
    A_counter = Counter(A)

    if(N%2==1):
        if(A_counter[0]==1 and all(A_counter[i]==2 for i in range(2, N, 2))):
            flag = True
    else:
        if(all(A_counter[i]==2 for i in range(1, N, 2))):
            flag = True
    
    print(pow(2, N//2, 10**9+7) if flag else 0)

if __name__ == '__main__': 
    N = int(input())
    A = [int(a) for a in input().split()]
    
    solve(N, A)

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

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

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

Solution (Python):
def judge_lie(n): return sum([abs(n + 1 -2*i) for i in range(1, n+1)])
n = int(input())
import sys
a = list(map(int,sys.stdin.readline().split()))
if sum(a) != judge_lie(n):
    print(0)
else:
    print((2 ** (n//2) % (10 ** 9 + 7)))

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

cnt = dict()

for i in range(n):
    cnt[i] = 0
for d in dat:
    cnt[d]+=1

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

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

if a == b:
    print(2 ** (N // 2) % MOD)
else:
    print(0)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
if N % 2 == 0:
    B = [i for i in range(1, N, 2)]
    B = B + B
    B = sorted(B)
else:
    B = [i for i in range(2, N, 2)]
    B = B + [0] + B
    B = sorted(B)

if A != B:
    print(0)
else:
    print(2 ** (len(B) // 2) % (10 ** 9 + 7))

Solution (Python):
from collections import Counter


N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)
ans = 0

if N % 2:
    if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
        ans = 2**(N//2) % mod
else:
    if all(countA[i] == 2 for i in range(1, N, 2)):
        ans = 2**(N//2) % mod


print(ans)

Solution (Python):
from collections import Counter


N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)
ans = 0

if N % 2:
    if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
        ans = pow(2, N//2) % mod
else:
    if all(countA[i] == 2 for i in range(1, N, 2)):
        ans = pow(2, N//2) % mod


print(ans)

Solution (Python):
from collections import Counter


N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)
ans = 0

if N % 2:
    if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
        ans = pow(2, N//2, mod)
else:
    if all(countA[i] == 2 for i in range(1, N, 2)):
        ans = pow(2, N//2, mod)


print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
from collections import Counter
C = Counter(a)
if n%2==0 and not a.count(0)==0:
    print(0)
    exit()
elif n%2==1 and not a.count(0)==1:
    print(0)
    exit()
for c in set(a):
    if not c==0 and not C[c]==2:
        print(0)
        exit()
print(2**(n//2)%(10**9+7))

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


m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  if m[i]!=2:
    ans=0
if m[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)

Solution (Python):
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
MOD = 1000000007

ndict = defaultdict(int)

for n in A:
  ndict[n] += 1

count = 1

for k, v in ndict.items():
  if v == 1 and k != 0:
    count = 0
    break
  else:
    count *= v
    count %= MOD

print(count)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = True
mod = 10 ** 9 + 7
for i,j in enumerate(a):
  if n % 2:
    if j != ((i+1) // 2) * 2:
      b = False
      break
  else:
    if j != (i // 2) * 2 + 1:
      b = False
      break
if b == True:
  print(pow(2,n//2,mod))
else:
  print(0)

Solution (Python):


people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False

for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*(i//2) +1):
            continue
        else:
            bool_false = False
            break

if(people_num == 1):
    print(1)
elif(bool_false):
    print((2**(people_num // 2) % (10**9 +7)))
else:
    print(0)

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A1 = {}
judge = 1

if(N%2 == 1):
  for i in range(N):
    if(A[i] in A1): A1[A[i]] += 1
    else: A1[A[i]] = 1
  count = -1
  for k, v in sorted(A1.items()):
    count += 1
    if(count == 0):
      if((k == 0)and(v == 1)):
        continue
      else: 
        judge = 0
        break
    else:
      if((k == 2*count)and(v == 2)):
        continue
      else:
        judge = 0
        break
    
 
else:
  for i in range(N):
    if(A[i] in A1): A1[A[i]] += 1
    else: A1[A[i]] = 1
  count = -1
  for k, v in sorted(A1.items()):
    count += 1
    if((k == 2*count+1)and(v == 2)):
       continue
    else:
        judge = 0
        break
    count += 1

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

Solution (Python):
import sys
from collections import Counter
sys.setrecursionlimit(10**7)
mo=10**9+7
n=10**5

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

ans=pow(2,(n//2),mo)
for i in range(n):
    if a[i]!=b[i]:
        ans=0


print(ans)

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


mod = 10**9+7
if N % 2 == 0:
    for i in range(1,N,2):
        B.append(i)
        B.append(i)
    for i in range(N):
        if A[i] != B[i]:
            print(0)
            exit()

    print(2**(N//2) % mod)
else:
    B.append(0)
    for i in range(2,N,2):
        B.append(i)
        B.append(i)
    for i in range(N):
        if A[i] != B[i]:
            print(0)
            exit()

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

Solution (Python):
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
a = nl()

c = collections.Counter(a)
mod = 10 ** 9 + 7

val = list(c.values())
key = list(c.keys())
check = len(a) % 2
if check == 1:
    if val.count(1) != 1:
        print(0)
        exit()
    if key[val.index(1)] != 0:
        print(0)
        exit()
    else:
        if val.count(2) != len(val) - 1:
            print(0)
            exit()
        else:
            print(2 ** (val.count(2)) % mod)
else:
    if val.count(2) != len(val):
        print(0)
        exit()
    else:
        print(2 ** (len(val)) % mod)

Solution (Python):
import collections
mod=10**9+7
p=int(input())
a=[int(i) for i in input().split()]
diff=collections.Counter(a)
def modpower(n):
    ret=1
    for k in range(n):
        ret=(2*ret)%mod
    return(ret)
if p==1:
    ans=1-bool(a[0])
elif p%2:
    if all([diff[i]==2 for i in range(2,p,2)]) and diff[0]==1:
        ans=modpower(p//2)
    else:ans=0
else:
    if all([diff[i]==2 for i in range(1,p+1,2)]):
        ans=modpower(p//2)
    else:ans=0
print(ans)

Solution (Python):
N=int(input())
A=sorted(list(map(int,input().split(' '))))
if N%2==1:
	B=[ ((i+1)//2)*2 for i in range(N) ]
	C=[ 0 if A[i]==B[i] else 1 for i in range(N) ]
	flag=True if sum(C)==0 else False
elif N%2==0:
	B=[ (i//2)*2+1 for i in range(N) ]
	C=[ 0 if A[i]==B[i] else 1 for i in range(N) ]
	flag=True if sum(C)==0 else False
print((2**(N//2))%(10**9+7)) if flag else print(0)

Solution (Python):
from collections import defaultdict
import sys

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

counts = defaultdict(int)
mod = N % 2

for a in A:
    if a % 2 == mod:
        print(0)
        sys.exit()
    counts[a] += 1
    if a == 0 and counts[a] > 1:
        print(0)
        sys.exit()
    if a > 0 and counts[a] > 2:
        print(0)
        sys.exit()

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

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):
N=int(input())

mp=[0 for i in range(N)]
for a in input().split():
    mp[int(a)]+=1

res=True
if N%2==1:
    for i in range(2,N,2):
        if mp[i]!=2:
            res=False
    if mp[0]!=1:
        res=False
else:
    for i in range(1,N,2):
        if mp[i]!=2:
            res=False
if res:
    print(pow(2,N//2,10**9+7))
else:
    print(0)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
count = [0 for _ in range(N+1)]

if N % 2 == 0:
    if len(set(A)) != int(N/2):
        print(0)
        exit()
else:
    if len(set(A)) != int(N/2)+1:
        print(0)
        exit()

for i in A:
    count[i] += 1



res = 1
for i in range(N+1):
    if count[i] == 2:
        res *= 2
    else:
        if count[i] != 0:
            if N % 2 == 1 and i != 0: 
                print(0)
                exit()

print(res % (10**9+7))

Solution (Python):
import math

N = int(input())
A = [int(_) for _ in input().split()]
A = sorted(A)
List = []

if N % 2 == 0:
    for i in range(N):
        List.append(i//2 * 2 + 1)
else:
    for i in range(N):
        List.append(math.ceil(i/2) * 2)

if A != List:
    print(0)
else:
    print(2**(N//2) % (10**9+7))

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    A = LI()
    from collections import Counter
    cnt = Counter(A)
    if N % 2 and cnt[0] < 0:
        return 0
    for i in range(N % 2 + 1, N, 2):
        if cnt[i] != 2:
            return 0
    ans = (2 ** (N // 2)) % MOD

    return ans

print(main())

Solution (Python):
import collections

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

Solution (Python):
def inpl():
    return list(map(int, input().split()))


N = int(input())

A = inpl()
A.sort()

if N % 2 == 1:
    a = 1
    if A[0] != 0:
        print(0)
        exit()
else:
    a = 0

ans = 1
for j, i in enumerate(range(a, N, 2)):
    if A[i] == A[i + 1] == 2 * (j + 1) - (a + 1) % 2:
        ans *= 2
    else:
        print(0)
        exit()
print(ans % (10**9 + 7))

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

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

Solution (Python):


"""
Created on Sat Feb  9 09:53:28 2019

@author: shinjisu
"""



def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def db(x):
    global debug
    if debug:
        print(x)


def solve():
    A.sort()
    db(A)
    if A[0] == 0:
        n = 1
    else:
        n = 0
    for i in range(n, len(A), 2):
        db(i)
        if A[i] != A[i+1]:
            return 0
    return 2**(len(A)//2) % (10**9+7)


debug = False
N = getInt()
A = getIntList()
db((N, A))
print(solve())

Solution (Python):
from math import factorial, floor
n = int(input())
a_list = list(map(int, input().split()))

co = a_list.copy()
if 0 in co:
    co.remove(0)
co.sort()


if not len(co) % 2 == 0:
    print(0)
    quit()

for index in range(len(a_list))[:-1:2]:
    if not co[index] == co[index + 1]:
        print(0)
        quit()


print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

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

ans=None
tmp=0
z=1
if(N%2==0):
    tmp=int(N/2)
    ans=[2 for i in range(tmp)]
    A=map(int,input().split())
    for i in A:
        if(int(i/2)<=int(N/2)):
            ans[int(i/2)-1]-=1
        else:
            print(0)
            exit() 
else:
    tmp=int(N/2)
    ans=[2 for i in range(tmp)]
    z=0
    A=map(int,input().split())
    for i in A:
        if(i==0):
            z=1
            continue
        if(int(i/2)<=int(N/2)):
            ans[int(i/2)-1]-=1
        else:
            print(0)
            exit()
output=2**(tmp)%(10**9+7)
for i in ans:
    if(i!=0):
        output=0

print(output*z)

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

if N % 2 == 1:
    l.append(0)
    N -= 1
else:
    l = list(map(lambda x: x-1, l))

l = sorted(l)
i = 0
for f, s in zip(l[0::2], l[1::2]):
    if f == 2*i and s == 2*i:
        i += 1
    else:
        print(0)
        exit()

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

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

Solution (Python):
n = int(input())
a = list(int(i) for i in input().split())
if n%2==0 and sum(a)==n*n//2 or n%2==1 and sum(a) == (n+1)*(n//2):
    print(2**(n//2)%(10**9+7))
else:
    print(0)

Solution (Python):


II = lambda: int(input())
MI = lambda: map(int, input().split())


def check(N, A):
    if N % 2 == 0:
        for i in range(N):
            if A[i] != (i // 2) * 2 + 1: return False
    else:
        for i in range(N):
            if A[i] != ((i + 1) // 2) * 2: return False
    return True

def main():
    N = II()
    A = sorted(list(MI()))
    if not check(N, A):
        return 0
    ans = 1
    MOD = int(1e9 + 7)
    for i in range(N//2):
        ans = ans * 2 % MOD
    return ans


if __name__ == "__main__":
    print(main())

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
judge = "YES"
if N % 2 == 1:
	if A[0] != 0:
		judge = "NO"
	for i in range(int(N // 2)):
		if A[2 * i + 1] != 2 * i + 2 or A[2 * i + 2] != 2 * i + 2:
			judge = "NO"
			break

else:
	for i in range(int(N // 2)):
		if A[2 * i] != 2 * i + 1 or A[2 * i + 1] != 2 * i + 1:
			judge = "NO"
			break

if judge == "NO":
	print(0)
else:
	c = 1
	for i in range(int(N // 2)):
		c = (2 * c) % 1000000007
	print(c)

Solution (Python):
import collections
MOD = 10**9 + 7

N = int(input())
A = input().split(' ')
flag = False
c = collections.Counter(A)


if c.most_common()[0][1] > 2:
    flag = True
if N % 2 == 1:
    if not c.most_common()[-1][0] == '0':
        flag = True
if flag:
    print(0)
    exit()

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

Solution (Python):
import collections
N=int(input())
A=list(map(int,input().split()))
if N%2==1:
    if 0 not in A:
        print(0)
    else:
        A.remove(0)
        Bc=dict(collections.Counter(A))
        for i in Bc.keys():
            if Bc[i]!=2:
                print(0)
                break
        else:
            print((2**(len(A)//2))%(10**9+7))
else:
    Bc=dict(collections.Counter(A))
    for i in Bc.keys():
        if Bc[i]!=2:
            print(0)
            break
    else:
        print((2**(len(A)//2))%(10**9+7))

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

A.sort()

if N % 2 == 0:
    middle = N // 2
    able = True
    for i in range(0,N,2):
        if A[i] != A[i+1]:
            able = False
            break
    if able:
        ans = 2**middle
    else:
        ans = 0
else:
    middle = N // 2
    able = True
    if A[0] == 0:
        for i in range(1,N,2):
            if A[i] != A[i+1]:
                able = False
                break
        if able:
            ans = 2**middle
        else:
            ans = 0
    else:
        ans = 0
        
print(ans%(10**9 + 7))

Solution (Python):
def inpl(): return [int(i) for i in input().split()]
import sys
from collections import defaultdict
H = defaultdict(lambda: 0)
N = int(input())
A = inpl()
mod = 10**9+7
if N%2:
    H[0] = -1
    for i in range(1, 1+N//2):
        H[2*i] = -2
else:
    for i in range(1, 1+N//2):
        H[2*i-1] = -2
for i in A:
    H[i] += 1
H = list(H.values())
if any(H):
    print(0)
    sys.exit()
print(2**(N//2)%mod)

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

check = [0]*(n//2 + n%2)
flag = True
for i in a:
    check[i//2] += 1
    if i%2 == n%2:
        flag = False
        break
    if (i//2 == 0 and n%2 == 1 and check[0] > 1) or check[i//2] > 2:
        flag = False
        break
if flag:
    print(2**(n//2) % (10**9 + 7))
else:
    print(0)

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

a.sort()
ra = a.copy()
a = a[0::2]
ra = ra[1::2]
ra.reverse()
a = ra + a
for i in range(n):
    if a[i] != abs(n - 1 - i * 2):
        print(0)
        sys.exit(0)
print(2 ** (n // 2) % 1000000007)

Solution (Python):
inf=(10**9)+7
N=int(input().strip())
a=list(map(int, input().split()))


a.sort()
fl=True

fl=True
if N%2==0:
    for i in range(0,N,2):
        if a[i]!=i+1 or a[i+1]!=i+1:
            fl=False
            break
else:
    if a[0]!=0:
        fl=False
    for i in range(1,N,2):
        if a[i]!=i+1 or a[i+1]!=i+1:
            fl=False
            break

if fl:
    print((2**(N//2))%inf)
else:
    print(0)

Solution (Python):
MOD = 1000000007
N = int(input())
A = [int(a) for a in input().split()]
cnt = [0] * N
for a in A:
  cnt[a] += 1

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

Solution (Python):
import sys
import collections
import itertools
import math
from collections import Counter
from collections import deque

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

d = 10**9 + 7

cnt = Counter(A)

sA = sorted(A)

if N % 2 == 0:
    i = 0
    for i in range(0, N - 1, 2):
        if sA[i] == sA[i + 1] and sA[i] == i + 1:
            pass
        else:
            print(0)
            sys.exit(0)
else:
    if sA[0] != 0:
        print(0)
        sys.exit(0)
    for i in range(1, N - 1, 2):
        if sA[i] == sA[i + 1] and sA[i] == i + 1:
            pass
        else:
            print(0)
            sys.exit(0)

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

sys.exit(0)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
center = 0
M = N//2
parity = N%2
capacity = [0 for _ in range(M)]
failed = False
for i in range(N):
    if a[i]%2 == parity:
        failed = True
        break
    if a[i] < 0 or a[i] > N-1:
        failed = True
        break
    if a[i] == 0:
        center += 1
    else:
        j = (N-a[i])//2
        capacity[j] += 1
if parity == 1 and center != 1:
    failed = True
answer = 1
MOD = 10**9+7
for c in capacity:
    if c!=2:
        failed = True
        break
    else:
        answer *= 2
        answer %= MOD

if failed:
    print(0)
else:
    print(answer)

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

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


def solve():
    cnt = {i + (1 - N % 2): 0 for i in range(0, 2 * N // 2, 2)}
    for a in A:
        if a not in cnt:
            return 0

        if N % 2 == 1:
            if a % 2 == 1:
                return 0
            cnt[a] += 1
        else:
            if a % 2 == 0:
                return 0
            cnt[a] += 1

    for key, value in cnt.items():
        if key == 0:
            if value != 1:
                return 0
        else:
            if value != 2:
                return 0

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


print(solve())

Solution (Python):
from collections import defaultdict
import sys
N=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
L=[0]*N
for i in range(N):
    L[A[i]]+=1
if N%2==0:
    for i in range(1,N,2):
        if L[i]!=2:
            print(0)
            sys.exit()
    print(pow(2,N//2,mod))
else:
    if L[0]!=1:
        print(0)
        sys.exit()
    for i in range(2,N,2):
        if L[i]!=2:
            print(0)
            sys.exit()
    print(pow(2,N//2,mod))

Solution (Python):
import sys

MOD = 10 ** 9 + 7

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

As.sort()

if N % 2: 
    for i in range(N):
        if As[i] != (i + 1) // 2 * 2:
            print(0)
            sys.exit(0)
else: 
    for i in range(N):
        if As[i] != i // 2 * 2 + 1:
            print(0)
            sys.exit(0)

ans = 1
for _ in range(N // 2):
    ans = (ans * 2) % MOD
print(ans)

Solution (Python):

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

flag=True
if N%2==0:
    l = [0 for i in range(N/2)]
    for i in range(N):
        if A[i]%2!=1 or A[i]>=N or A[i]<=0:
            print 0
            flag=False
            break
        l[(A[i]-1)/2]+=1
        if l[(A[i]-1)/2]>=3:
            print 0
            flag=False
            break
    if flag:
        print (2**(N/2))%(10**9+7)
else:
    l = [0 for i in range((N+1)/2)]
    for i in range(N):
        if A[i]%2!=0 or A[i]>=N or A[i]<0:
            print 0
            flag=False
            break
        if A[i]==0:
            l[0]+=1
            if l[0]>=2:
                print 0
                flag=False
                break
        else:
            l[A[i]/2]+=1
            if l[A[i]/2]>=3:
                print 0
                flag=False
                break        
    if flag:
        print (2**((N-1)/2))%(10**9+7)

Solution (Python):
i = int(input())
list_a = list(map(int, input().split()))
dict_ans = {}
for number in list_a:
    try:
        dict_ans[number] += 1
    except KeyError:
        dict_ans[number] = 1
if i % 2 == 0:
    dict_prop = {key:2 for key in [j for j in range(i) if j % 2 == 1]}
    if dict_prop == dict_ans:
        ans = 2 ** (i//2)
    else:
        ans = 0
else:
    dict_prop = {key:2 for key in [j for j in range(i) if j % 2 == 0]}
    dict_prop.update({0:1})
    if dict_prop == dict_ans:
        ans = 2 ** (i // 2)
    else:
        ans = 0
print(ans % (10 **9 + 7))