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
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=sorted(map(int,input().split()),reverse=True)
m=n-1
for i in range(n//2):
    if aa[2*i]!=m or aa[2*i+1]!=m:
        print(0)
        sys.exit()
    m-=2
print((2**(n//2))%(10**9+7))

Solution (Python):
import math
N=int(input())
A=list(map(int,input().split()))
flag=True
if N%2==0:
    if 0 in A or len(set(A))!=N//2:flag=False
else:
    if len([0 for a in A if a==0])!=1 or len(set(A))!=N//2+1:flag=False
if flag: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
A.sort()
B = []

ans = 1

if len(A) % 2 == 0:
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 1)
        B.append(2 * i + 1)

else:
    B.append(0)
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 2)
        B.append(2 * i + 2)

if A == B:
    print(int(ans))
else:
    print(0)

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

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

bucket = [0 for _ in range(N)]

if N % 2 == 0:
	even = True
else:
	even = False

Not0 = True

for i in range(N):
	if even:
		if A[i] % 2 == 0:
			print(0)
			Not0 = False
			break
		else:
			if bucket[A[i]] == 2:
				print(0)
				Not0 = False
				break
			else:
				bucket[A[i]] += 1
	else:
		if A[i] % 2 == 1:
			print(0)
			Not0 = False
			break
		else:
			if bucket[A[i]] == 2:
				print(0)
				Not0 = False
				break
			else:
				bucket[A[i]] += 1

if Not0:
	if not even:
		if bucket[0] != 1:
			print(0)
			Not0 = False

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

Solution (Python):
from collections import Counter
n = int(input())
lst = [int(i) for i in input().split()]
mod = 10**9 + 7
lst_c = Counter(lst)
lst_c = sorted(lst_c.items(),key = lambda x:x[0])

ideal = []

if n%2!=0:
    ideal.append((0,1))
    for i in range(1,n//2+1):
        ideal.append((2*i,2))
else:
    for i in range(n//2):
        ideal.append((2*i+1,2))

if lst_c != ideal:
    print(0)
else:
    l = len(ideal)
    if n%2!=0:
        l -= 1
    print(2**l % mod)

Solution (Python):
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
A.sort()


T=[]
if n%2==0:
    for i in range(n//2):
        T.append(2*i+1)
        T.append(2*i+1)
else:
    T.append(0)
    for i in range(n//2):
        T.append(2*i+2)
        T.append(2*i+2)
        
for i in range(n):
    if A[i] != T[i]:
        print(0)
        break
else:
    print((2**(n//2))%mod)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()
mod = 10**9 + 7
ans = (2 ** (n // 2)) % mod
b = []
for i in range(n):
  b += [abs(n+1-2*(i+1))]
b.sort()

if a == b :
  print(ans)
else:
  print(0)

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


def solve(N, A):
    counter = Counter(A)
    if N % 2 == 1:
        for a, n in counter.items():
            if a == 0 and n == 1:
                continue
            if a % 2 != 0 or n != 2:
                return 0
        return (2**(N//2)) % 1000000007
    else:
        for a, n in counter.items():
            if a % 2 != 1 or n != 2:
                return 0
        return (2**(N//2)) % 1000000007

print(solve(N, A))

Solution (Python):

import sys, math, fractions, itertools, collections

MOD = 1000000007  

def mpow(n, base):
    res = 1
    for i in range(n):
        res = res * base % MOD
    return res

def solve(N: int, A: "List[int]"):
    A.sort()
    if N % 2 == 0:
        for i in range(0, N//2):
            if A[2*i] != 2*i+1 or A[2*i+1] != 2*i+1:
                print(0)
                return
        print(mpow(N//2, 2))
    else:
        for i in range(0, N//2):
            if i == 0:
                if A[0] != 0:
                    print(0)
                    return
                else:
                    continue
            if A[2*i] != 2*i or A[2*i-1] != 2*i:
                print(0)
                return
        print(mpow(N//2, 2))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
import math
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
half = math.floor(N/2)
ans = 2**(half)
if N%2 == 1 and A[-1] !=0:
  ans = 0
for i in range(half):
  if A[2*i] == N-2*i-1 and A[2*i+1] == N-2*i-1:
    continue
  else:
    ans = 0
    break
print(ans%(10**9+7))

Solution (Python):
N = int(input())
nums = list(map(int, input().split()))
n_dict = {}
idx = 0
mod = ((N%2)+1)%2
while True:
  if 2*idx + mod > N:
    break
  else:
    n_dict[2*idx+mod] = 0
  idx += 1
for num in nums:
  if num in n_dict:
    n_dict[num] += 1
  else:
    print(0)
    exit()
for key, value in n_dict.items():
  if value != 2 and key != 0:
    print(0)
    exit()
print((2**(N//2))%(10**9+7))

Solution (Python):
N = int(input())
A = list(map(int, input().rstrip().split()))
A.sort()
ANS = 2**(N//2)

if N%2 == 0:
    if A[0] and A[1] != 1:
        print(0)
        exit()
    elif N == 2:
        if A[0] != A[1]:
            print(0)
            exit()
    else:
        for i in range(2,N,2):
            if A[i] != A[i+1] or A[i] - A[i-2] != 2:
                print(0)
                exit()
else:
    if A[0] != 0:
        print(0)
        exit()
    elif N == 3:
        if A[1] != A[2]:
            print(0)
            exit()
    else:
        for i in range(3,N,2):
            if A[i] != A[i+1] or A[i] - A[i-2] != 2:
                print(0)
                exit()

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

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


rowdata=[int(i) for i in input().split()]
rowdata.sort()


if n%2==0:
    check=[]
    a=1
    for i in range(1,n,2):
        check.append(i)
        check.append(i)
    if check==rowdata:
        for i in range(int(n/2)):
            a*=2
            a=a%1000000007
        print(a)
    else:
        print(0)
        

else:
    check=[]
    a=1
    if n==1:
        check=[0]
    else:
        for i in range(0,n,2):
            if i==0:
                check.append(i)
            else:
                check.append(i)
                check.append(i)
    if check==rowdata:
        for i in range(int((n-1)/2)):
            a*=2
            a=a%1000000007
        print(a)
    else:
        print(0)

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

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

if n == 1:
    if a[0] == 0:
        print(1)
    else:
        print(0)
    exit()



if n % 2 == 1:
    ans = 2 ** ((n-1) // 2)
else:
    ans = 2 ** (n//2)


if n % 2 == 1:
    for i in range(n):
        if i == 0:
            if a[i] == 0:
                continue
            else:
                print(0)
                exit()
        else:
            if a[i] == math.ceil(i/2)*2:
                continue
            else:
                print(0)
                exit()
else:
    for i in range(n):
        if a[i] == math.floor(i/2)*2+1:
            continue
        else:
            print(0)
            exit()

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

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
mod = int(1E9+7)

B = Counter(A)
c = (N+1)%2

ans = 1
for k, v in B.items():
    if k%2 != c or (k!=0 and v != 2):
        ans = 0
        break
    ans = ans * v % mod

print(ans)

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

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

sorted_l = sorted(l)

w = 0

if n % 2 == 0:
    k = 1
    for i in range(n):
        if k != sorted_l[i]:
            w += 1
        
        if i % 2 == 1:
            k += 2
            
else:
    if sorted_l[0] != 0:
        w += 1
    k = 2
    for i in range(1,n):
        if k != sorted_l[i]:
            w += 1
        
        if i % 2 == 0:
            k += 2
            
if w != 0:
    print(0)

else:
    b = n // 2
    ans = 1
    for i in range(1,b+1):
        ans*= 2
        ans%=(10**9)+7
        
    print(ans)

Solution (Python):

from collections import Counter
import sys

def main():

    num = int(input())
    data = list(map(int, input().split()))
    count_data = Counter(data)
    mod = 10 ** 9 + 7

    if num % 2 == 1:
        if count_data[0] != 1:
            print(0)
            sys.exit()
        for i in range(1, (num // 2) + 1):
            if count_data[i * 2] != 2:
                print(0)
                sys.exit()

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

    ans = pow(2, num // 2, mod)
    print(ans)




if __name__ == '__main__':
    main()

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

Solution (Python):
import collections
N = int(input())
A = [int(i) for i in input().split()]
count = collections.Counter(A)
ans = 0
if N%2 == 1:
  for k,v in count.items():
    if k%2 == 1 or (k != 0 and v != 2):
      break
  else:
    ans = 2**(N//2)
else:
  for k,v in count.items():
    if k%2 == 0 or v != 2:
      break
    else:
      ans = 2**(N//2)
print(ans%(10**9+7))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a = LS()
    if a[1][0] == "+":
        print(int("".join(a[0])) + int("".join(a[2])))
    else:
        print(int("".join(a[0])) - int("".join(a[2])))
    return


def B():
    return


def C():
    n = II()
    a = LI()
    d = defaultdict(int)
    ans = 1
    if n & 1:
        for i in a:
            if i & 1:
                print(0)
                return
            d[i] += 1
        for a, b in d.items():
            if a:
                if b == 2:
                    ans *= 2
                    ans %= mod
                    continue
                print(0)
                return
            if b == 1:
                continue
            print(0)
            return
    else:
        for i in a:
            if i & 1:
                d[i] += 1
                continue
            print(0)
            return
        for a, b in d.items():
            if b == 2:
                ans *= 2
                ans %= mod
                continue
            print(0)
            return
    print(ans)
            
        
    return


def D():
    return



if __name__ == '__main__':
    C()

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
flag = N % 2 == 0
if not flag:
	flag = A[0] == 0
if flag:
	index = N % 2
	while index < N:
		if A[index] != index + 1 or A[index] != A[index]:
			flag = False
			break
		index += 2
if flag:
	print((2**(N//2))%(10**9+7))
else:
	print(0)

Solution (Python):

import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  

def solve(N: int, A: "List[int]"):
    count = [0] * N
    for a in A:
        if a % 2 == N % 2:
            print(0)
            return
        count[a] += 1
    if N % 2 == 1 and count[0] == 1:
        count = count[1:]
    for cnt in count:
        if cnt != 0 and cnt != 2:
            print(0)
            return
    ret = (2 ** (N // 2)) % MOD
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(raw_input())
A = map(int, raw_input().split())
A.sort(reverse=True)
success = True
el = n - 1
for i in range(0, len(A)-1, 2):
    if A[i] != el or A[i+1] != el:
        success = False
        break
    el -= 2
if n % 2 == 1:
    if A[-1] != 0:
        success = False
else:
    if A[-1] != 1 or A[-2] != 1:
        success = False
if success:
    print pow(2, n/2, 10**9+7)
else:
    print 0

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
import collections
import numpy as np
import sys
count = collections.Counter(A)
loops = np.arange(N-1,-1,-2)

for li in list(loops):
    if li == 0 :
        if count[li] != 1:break
    else:
        if count[li] != 2:break

else:
    b = N//2
    ans = 1
    for i in range(1,b+1):
        ans *= 2
        ans %= mod
    print(ans)   
    sys.exit()

print(0)

Solution (Python):
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(sc.next());
		Arrays.sort(a);
		boolean able = true;
		if (n % 2 > 0) {
			for (int i = 0; i < n; i++) {
				if (i % 2 == 0 && a[i] == i) continue;
				if (i % 2 > 0 && a[i] == i + 1) continue;
				able = false;
			}
		}
		else {
			for (int i = 0; i < n; i++) {
				if (i % 2 == 0 && a[i] == i + 1) continue;
				if (i % 2 > 0 && a[i] == i) continue;
				able = false;
			}
		}
		if (able) {
			long ans = 1;
			for (int i = 1; i <= n / 2; i++)
				ans = ans * 2 % 1000000007;
			System.out.println(ans);
		}
		else
			System.out.println("0");
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Solution (Python):
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(sc.next());
		Arrays.sort(a);
		boolean able = true;
		if (n % 2 > 0) {
			for (int i = 0; i < n; i++) {
				if (i % 2 == 0 && a[i] == i) continue;
				if (i % 2 > 0 && a[i] == i + 1) continue;
				able = false;
			}
		}
		else {
			for (int i = 0; i < n; i++) {
				if (i % 2 == 0 && a[i] == i + 1) continue;
				if (i % 2 > 0 && a[i] == i) continue;
				able = false;
			}
		}
		if (able) {
			long ans = 1;
			for (int i = 1; i <= n / 2; i++)
				ans = ans * 2 % 1000000007;
			System.out.println(ans);
		}
		else
			System.out.println("0");
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Solution (Python):
from math import ceil

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

A.sort()

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

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

Solution (Python):
from math import ceil
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

A.sort()

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

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

Solution (Python):
from math import ceil
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

A.sort()

if N % 2 == 1:
    num = (N - 1) // 2
    if A[0] != 0:
        print(0)
        exit()
    for i in range(1, N):
        if A[i] == ceil(i / 2) * 2:
            continue
        else:
            print(0)
            exit()
else:
    num = N // 2
    for i in range(N - 1):
        if A[i] == (i // 2) * 2 + 1:
            continue
        else:
            print(0)
            exit()
ans = 1
for i in range(num):
    ans *= 2
    ans %= (10**9 + 7)

print(ans)

Solution (Python):
from math import ceil
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

A.sort()

if N % 2 == 1:
    num = (N - 1) // 2
    if A[0] != 0:
        print(0)
        exit()
    for i in range(1, N):
        if A[i] == ceil(i / 2) * 2:
            continue
        else:
            print(0)
            exit()
else:
    num = N // 2
    for i in range(N - 1):
        if A[i] == (i // 2) * 2 + 1:
            continue
        else:
            print(0)
            exit()
ans = 1
for i in range(num):
    ans *= 2
    ans %= (10**9 + 7)

print(ans)

Solution (Python):
c = int(input())
n = list(map(int,input().split()))
flag =True
n.sort()
if(len(n)%2==0):
	count=1
else:
	count=2
	if(n.pop(0)!=0):
		flag = False
		print('not 0 false')
while flag:
	if(len(n)==0): break
	if(not count==n.pop(0)==n.pop(0)):
		flag=False
	count += 2

if flag:
	ans = 2**int(c/2)
else:
	ans = 0
print(ans%(10**9+7))

Solution (Python):
import itertools
N = input()
l = list(map(int,input().split(" ")))
l.sort()
N = int(N)
flag = True
NUM = 10** 9 + 7
num = 2
if N %2 != 0:
    if l[0] != 0:
        flag =False
    num = 2
    start = 1
else:
    num = 1
    start = 0
for i in range(start,N,2):
    if l[i] != l[i + 1]   or l[i] != num:
        flag = False
    else:
        num += 2
if flag:
    temp = (N - start)//2
    print(2 ** temp %NUM )
else:
    print(0)

Solution (Python):

N = int(input())

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

dic = {}


for i in A:

    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1



if N % 2 == 0:

    flag = True
    now = 1

    for i in range(N // 2):

        if now not in dic or dic[now] != 2:
            flag = False
            break

        now += 2

    if len(dic) != N // 2:
        flag = False

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

    else:
        print (0)

else:

    flag = True
    now = 2

    if 0 not in dic or dic[0] != 1:
        flag = False

    for i in range(N // 2):

        if now not in dic or dic[now] != 2:
            flag = False
            break
        now += 2

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

    else:
        print (0)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
MOD = 10 ** 9 + 7

def judge() :
    p = N % 2
    c = [0] * ((N + 1) // 2)

    for a in A :
        if a % 2 == p or a < 0 or N <= a :
            return 0
            
        c[a//2] += 1
 
    if p == 1 and c[0] == 1 and c[1:].count(2) == (N - 1) // 2 :
        return pow(2, (N - 1) // 2, MOD)
    
    elif p == 0 and c.count(2) == N // 2 :
        return pow(2, N // 2, MOD)
        
    return 0
    
print(judge())

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

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


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

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

A.sort()
mod = 10 ** 9 + 7
i = 0
res = 0
if N == 1:
  if A[0] == 0:
    print(1)
  else:
    print(0)
  exit(0)
if N % 2 == 1:
  res = 1
  i = 1
  if A[0] == A[1]:
    print(0)
    exit(0)
  if A[0] == 1:
    print(0)
    exit(0)
else:
  res = 2
  i = 2
  if A[0] != A[1]:
    print(0)
    exit(0)
  if A[0] == 0:
    print(0)
    exit(0)
while i < N - 1:
  if A[i] == A[i + 1]:
    if N % 2 == 0:
      if A[i] != 2 * (i / 2 + 1) - 1:
        res = 0
        break
    else:
      if A[i] != 2 * (i // 2 + 1):
        res = 0
        break
    res *= 2
    i += 2
  else:
    res = 0
    break
print(res % mod)

Solution (Python):



from collections import Counter
from operator import itemgetter

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

c = Counter(a)
c = list(c.items())
ccc = sorted(c,key = itemgetter(0))
if n % 2 == 1:
    k = 0
    for i,j in ccc:
        if j == 2 and i == 2*k:
            k += 1
            continue
        if j == 1 and i == 0:
            k += 1
            continue
        else:
            print(0)
            quit()
if n % 2 == 0:
    k = 0
    for i,j in ccc:
        if j == 2 and i == 2*k+1:
            k += 1
            continue
        else:
            print(0)
            quit()
print(2**(n//2) % mod)

Solution (Python):
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""

def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
n = ip()
a = iprow()
b = sorted(a)
if n%2:
    s = 2
else:
    s = 1
    b.insert(0,0)
if n%2 != 0 and b[0] != 0:
    print(0)
    exit(0)
for i in range(1,n):
    if b[i]!=s:
        print(0)
        exit(0)
    if i%2 == 0:
        s+=2
print(pow(2,n//2,rem))

Solution (Python):
from collections import Counter
def main():
    mod = 10**9+7
    n = int(input())
    a = list(map(int,input().split(' ')))
    c = Counter(a)
    ans = (2**(n//2))%mod
    if n%2 != 0:
        for key,i in c.items():
            if key%2 != 0 or (key==0 and i != 1) or (key != 0 and i != 2):
                ans = 0
                break
    else:
        for key,i in c.items():
            if key%2 ==0 or i !=2:
                ans = 0
                break

    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
def main():
    mod = 10**9+7
    n = int(input())
    a = list(map(int,input().split(' ')))
    c = Counter(a)
    ans = 1
    if n%2 != 0:
        for key,i in c.items():
            if key%2 != 0 or (key==0 and i != 1) or (key != 0 and i != 2):
                ans = 0
                break
            elif i ==2:
                ans *=2
                ans %= mod
    else:
        for key,i in c.items():
            if key%2 ==0 or i !=2:
                ans = 0
                break
            elif i ==2:
                ans *=2
                ans %= mod
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

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

D = defaultdict(lambda: 0)
for a in A:
    D[a] += 1

if n % 2 == 0:
    for a in range(1, n, 2):
        if D[a] != 2:
            print(0)
            exit()
else:
    if D[0] != 1:
        print(0)
        exit()
    for a in range(2, n, 2):
        if D[a] != 2:
            print(0)
            exit()

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

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

l = {}
ll = {}

if n % 2 == 0:
  for i in m:
    l[2*(i//2)+1] = 2
    if i in ll:
      ll[i] += 1
    else:
      ll[i] = 1
else:
  for i in m:
    if 2*(i//2) == 0:
      l[2*(i//2)] = 1
    else:
      l[2*(i//2)] = 2
    if i in ll:
      ll[i] += 1
    else:
      ll[i] = 1

if l != ll:
  print(0)
  exit()

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

Solution (Python):
N = int(input())
Al = list(map(int,input().split()))
Al.sort()
Bl = []

if N % 2 == 0:
  for i in range(1,N+1,2):
    Bl.append(i)
    Bl.append(i)

else:
  Bl.append(0)
  for i in range(2,N+1,2):
    Bl.append(i)
    Bl.append(i)

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

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

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    if kigu==a[i]%2:
        print(0)
        quit()
    kakunin[a[i]]+=1

for i in range(n):
    
    
    
    
    
    if kigu==0 and i%2==1:
        if kakunin[i]!=2:
            print(0)
            quit()
    if kigu==1 and i%2==0:
        if i==0 and kakunin[i]!=1:
            print(0)
            quit()
        elif i!=0 and kakunin[i]!=2:
            print(0)
            quit()

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

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

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    kakunin[a[i]]+=1
    

for i in range(n):
    if kigu==0:
        if i%2==1 and kakunin[i]!=2:
            print(0)
            quit()
        elif i%2==0 and kakunin[i]!=0:
            print(0)
            quit()

    if kigu==1:
        if i==0:
            if kakunin[i]!=1:
                print(0)
                quit()
        elif i%2==0 and kakunin[i]!=2:
            print(0)
            quit()
        elif i%2==1 and kakunin[i]!=0:
            print(0)
            quit()

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

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

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

N = int(input())
a = list(map(int,input().split()))
b = set()
for c in a:
    if c in b:b.remove(c)
    else:b.add(c)

if N%2==1:
    if b == {0}:print(power_func(2,N//2,10**9+7))
    else:print(0)
else:
    if len(b) == 0:print(power_func(2,N//2,10**9+7))
    else:print(0)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
mod = 10**9+7
if n % 2 == 0 and len(set(l)) == n//2:
  print(2**(n//2)%mod)
elif not n % 2 == 0 and l.count(0) == 1:
  print(2**((n-1)//2)%mod)
else:
  print(0)

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

for i in range(N):
    if A.count(i) == 2 and i != 0:
        c += 1
    elif A.count(i) == 1 and i == 0:
        continue
    elif A.count(i) == 0:
        continue
    else:
        break
'''
c = N // 2
if N % 2 == 0:
    K = N
else:
    K = N + 1 
if sum(A) == c * K:
    ans = 2 ** c % (10**9 + 7)
else:
    ans = 0

print(ans)

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

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

A.sort(reverse=True)

length = len(A)
if not length % 2 == 0:
    length -= 1

for i in range(0, length, 2):
    if not A[i] == A[i + 1]:
        print(0)
        exit()

print((2 ** (length // 2)) % NUM)

Solution (Python):


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

for i, a in enumerate(A):
    if N % 2 == 0:
        if a != i // 2 * 2 + 1:
            print(0)
            exit()
    else:
        if a != (i + 1) // 2 * 2:
            print(0)
            exit()

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

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





















K = N if N % 2 == 0 else N + 1
S = N // 2
if sum(A) == K * S:
    ans = 2 ** S % (10 ** 9 + 7)
else:
    ans = 0

print(ans)

Solution (Python):
n = int(input())
diff=[int(s) for s in input().split()]
diff.sort()
MOD=10**9+7


start=0
if n&1==1:
    start=1
    if diff[0]!=0:
        print(0)
        exit()

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

    ans=ans*2%MOD

print(ans)

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

A = list(sorted(A))
flag = 0
for i in range(N//2-1):
    if N % 2 == 1:
        if A[2*i+1]==A[2*i+2] and A[2*i+1] == 2*i+2 and A[0] == 0:
            pass;
        else:
            flag = -1
            break;
    if N % 2 == 0:
        if A[2*i]==A[2*i] and A[2*i+1] == 2*i+1:
            pass;
        else:
            flag = -1
            break;
if flag == 0:
    ans = 2**(N//2)%(10**9+7)
    print (ans)
else:
    print(0)