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 numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n = int(input())
A = iarr()
s = set(A)
if sum(A)==2*sum(s): print(pow(2, len(A)//2, int(1e9+7)))
else: print(0)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7



N = INT()
A = LIST()
A.sort()

if N%2:
	for i in range(N):
		if A[i] != -(-i//2) *2:
			print(0)
			break
	else:
		print(pow(2, N//2, mod))

else:
	for i in range(N):
		if A[i] != i//2*2 +1:
			print(0)
			break
	else:
		print(pow(2, N//2, mod))

Solution (Python):
from collections import Counter
from math import ceil

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


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

THE_NUM = 10**9 + 7

is_exist_liar = False

for a in A:
  
  place_left = (N - 1 - a) // 2
  if (N - 1 - a) % 2 == 0 and place_left >= 0:
    possibility[place_left] += 1
  else:
    is_exist_liar = True
    break

answer = 1

for i in range(N // 2):
  if possibility[i] <= 2:
    answer *= possibility[i]
  else:
    is_exist_liar = True
    break


if is_exist_liar or N % 2 == 1 and possibility[N//2] >= 2:
  print(0)
else:
  print(answer % THE_NUM)

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

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

n = int(input())
a = list(map(int, input().split()))
freq = Counter(a)
ordering = []
for i in range(n):
    right = n - i - 1
    left = i
    ordering.append(abs(right - left))
freq2 = Counter(ordering)
if freq != freq2:
    print(0)
else:
    result = 1
    for x in freq.values():
        result *= x
    print(result % (10 ** 9 + 7))

Solution (Python):
n, *A = map(int, open(0).read().split())
if n % 2:
    d = {i:2 for i in range(0, n, 2)}
    d[0] -= 1
else:
    d = {i:2 for i in range(1, n, 2)}
for a in A:
    if a in d:
        d[a] -= 1
    else:
        print(0)
        exit()

if any(d.values()):
    print(0)
else:
    print(pow(2, n//2, 10**9 + 7))

Solution (Python):
from collections import Counter
def main():
    n = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    mod = 1000000007
    if n % 2 == 0:
        if any([a % 2 == 0 for a in A]) or any([v != 2 for v in c.values()]):
            print(0)
            exit()

    else:
        if any([a % 2 != 0 for a in A]) or any([v != 2 if k != 0 else v != 1 for k, v in c.items()]):
            print(0)
            exit()
    print(pow(2, n // 2, mod))    


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split(' ')))
    
    
    
    count = [0 for _ in range(N // 2 + 1)]
    for a in A:
        if (N - 1 - a) % 2 > 0:
            print(0)
            return
        left = (N - 1 - a) // 2  
        count[left] += 1
    for i in range(len(count)):
        c = count[i]

        if i == N // 2:
            if N % 2 > 0 and c != 1:
                print(0)
                return
        else:
            if c != 2:
                print(0)
                return
    
    ans = 1
    for _ in range(N // 2):
        ans *= 2
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import collections
n = int(input())
a = list(map(int,input().split()))
ac = collections.Counter(a)
ac = list(ac.items())
ac.sort()


mod = int(1e9+7)
ans = 1
if n % 2 == 0:
    for i in range(1,n,2):
        if ac[i//2][0] != i or ac[i//2][1] != 2:
            print(0)
            exit()
        else:
            ans *= 2
            ans %= mod
else:
    for i in range(0, n, 2):
        if i == 0:
            if ac[i//2][0] != i or ac[i//2][1] != 1:
                print(0)
                exit()
        else:
            if ac[i//2][0] != i or ac[i//2][1] != 2:
                print(0)
                exit()
            else:
                ans *= 2
                ans %= mod
print(ans)

Solution (Python):
from sys import exit
N = int(input())
A = map(int,input().split())
B = [0]*N
for i in A:
  B[i] += 1
if N%2 == 1:
  if B[0] != 1:
    print(0)
    exit()
  for i in range(1,N):
    if i%2 == 1 and B[i] != 0:
      print(0)
      exit()
    elif i%2 == 0 and B[i] != 2:
      print(0)
      exit()
else:
  for i in range(N):
    if i%2 == 1 and B[i] != 2:
      print(0)
      exit()
    elif i%2 == 0 and B[i] != 0:
      print(0)
      exit()
print(pow(2,N//2,1000000007))

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
c=Counter(lis)
if n%2==1:
    flag=True
    if c[0]!=1:
        flag=False
    for i in c.keys():
        if i!=0 and c[i]!=2:
            flag=False
    if flag==False:
        print(0)
    else:
        print(pow(2,(n-1)//2,mod))
else:
    flag=True
    for i in c.keys():
        if c[i]!=2:
            flag=False
    if flag==False:
        print(0)
    else:
        print(pow(2,n//2,mod))

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
flag = True
c = Counter(a)

if n % 2 == 1:
    if c[0] != 1:
        flag = False
    for i in range(1, n//2+1):
        if c[i*2] != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)
elif n % 2 == 0:
    for i in range(n//2):
        if c[i*2+1] != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)

Solution (Python):
n = int(input())
nums = sorted(map(int, input().split()))
if n % 2 == 0:
    if nums[::2] != nums[1::2]:
        print(0)
    else:
        print(2 ** (n // 2) % 1000000007)
else:
    if nums[0] == 0 and nums[1::2] == nums[2::2]:
        print(2 ** (n // 2) % 1000000007)
    else:
        print(0)

Solution (Python):
from collections import Counter
import numpy as np

MOD = 10 ** 9 + 7

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

num = len(a)
ans = 1


if (num % 2 == 0):
    
    temp = 1
    loop = int(num / 2)
    for i in range(loop):
        tar = count[temp]
        if (tar == 2):
            ans *= 2
            temp += 2
        else:
            print(0)
            exit()

else:

    tar0 = count[0]
    if (tar0 == 1):
        pass
    else:
        print(0)
        exit()

    temp = 2

    for i in range(num // 2):
        if (count[temp] == 2):
            ans *= 2
            temp += 2
        else:
            print(0)
            exit()

ans %= MOD
print(ans)

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

for i in range(N):
    a_comb.append(abs(i - (N - 1 - i)))

if sorted(a_comb) == sorted(a):
    print(2 ** (N // 2) % mod)
else:
    print(0)

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

from collections import Counter
c=Counter(a)

cnt_lst=[0]*n
for key in c:
    cnt_lst[key]+=c[key]

flag=True
if n%2==1:
    if cnt_lst[0]==1:
        cnt_lst.pop(0)
    else:
        flag=False
    for i in range(n-1):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            flag=False
else:
    for i in range(n):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            flag=False

print(2**(n//2)%mod if flag else 0)

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

from collections import Counter
c=Counter(a)

cnt_lst=[0]*n
for key in c:
    cnt_lst[key]+=c[key]

flag=True
if n%2==1:
    if cnt_lst[0]==1:
        cnt_lst.pop(0)
    else:
        flag=False
    for i in range(n-1):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            flag=False
else:
    for i in range(n):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            flag=False

print(pow(2,(n//2),mod) if flag else 0)

Solution (Python):
from collections import Counter

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

combi = []
for i in range(n):
    l = i
    r = n - i - 1
    combi.append(abs(l - r))

if sorted(combi) == sorted(a):
    c = Counter(combi)
    ans = 1
    for i in c.values():
        ans *= i
        ans %= mod
else:
    ans = 0

print(ans)

Solution (Python):
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 A.count(0)!=1 or len(set(A))!=(n+1)//2:
        flag=False
if flag:
    print(2**(n//2)%(10**9+7))
else:
    print(0)

Solution (Python):
import collections

n = int(input())
lst = [int(s) for s in input().split()]

is_success = True

if n % 2 == 1:
    is_success = lst.count(0) == 1

counters = collections.Counter(lst)

for i in range(n - 1, 0, -2):
    if counters[i] != 2:
        is_success = False
        break

if is_success:
    tmp = 1

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

    print(tmp)
else:
    print(0)

Solution (Python):
import collections

n = int(input())
lst = [int(s) for s in input().split()]

is_success = True

if n % 2 == 1:
    is_success = lst.count(0) == 1

counters = collections.Counter(lst)

for i in range(n - 1, 0, -2):
    if counters[i] != 2:
        is_success = False
        break

if is_success:
    tmp = 1

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

    print(tmp)
else:
    print(0)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
s = set(a)
limit = 10**9+7
if sum(a) == 2 * sum(s):
    print(2**(n//2)%limit)
else:
    print(0)

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

result = 0
if N % 2 != 0:
  cor = [0]
  for i in range(1,int(N/2)+1):
    cor.append(i*2)
    cor.append(i*2)
  if sorted(a) == cor:
    result = 2**int((N-1)/2) % (10**9 + 7)
else:
  cor = []
  for i in range(1,int(N/2)+1):
    cor.append(i*2-1)
    cor.append(i*2-1)
  if sorted(a) == cor:
    result = 2**int(N/2) % (10**9 + 7)
    
print(result)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
A = IL()

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


for a in A:
  correct[a] -= 1
  
if correct != [0 for i in range(N+1)]:
  print(0)
else:
  print(pow(2,N//2,MOD))

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

if N % 2 == 1:

    memo = {key:0 for key in [i for i in range(2, N, 2)]}

    for a in A:
        try:
            memo[a] += 1
        except:
            memo[a] = 1



    check_list = {}
    for i in range(2, N, 2):
        check_list[i] = False

    for check_num in check_list.keys():
        if check_num == 0:
            if memo[check_num] != 1:
                print(0)
                quit()
        if memo[check_num] != 2:
            print(0)
            quit()

else:
    memo = {key:0 for key in [i for i in range(1, N, 2)]}

    for a in A:
        try:
            memo[a] += 1
        except:
            memo[a] = 1



    check_list = {}
    for i in range(1, N, 2):
        check_list[i] = False

    for check_num in check_list.keys():
        if memo[check_num] != 2:
            print(0)
            quit()

ans = pow(2, len(check_list))
ans %= mod
print(ans)

Solution (Python):
from collections import Counter

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


if N % 2 == 0:
    for key, value in A.items():
        if key % 2 != 1:
            print(0)
            exit()
    for i in range(1, N, 2):
        if A[i] != 2:
            print(0)
            exit()
    print(pow(2, N//2, mod))
else:
    if A[0] != 1:
        print(0)
        exit()
    for key, value in A.items():
        if key % 2 != 0:
            print(0)
            exit()
    for i in range(2, N, 2):
        if A[i] != 2:
            print(0)
            exit()
    print(pow(2, N // 2, mod))

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

Solution (Python):
t = int(input())
m = list(map(int,input().split()))
q={}
mod=10**9+7
z=False
cnt0=0
for i in range(t):
    d=m[i]
    a=(t-1-d)//2
    if d==0:
        cnt0+=1
    if (a,a+d) not in q:
        q[(a,a+d)]=0
    q[(a,a+d)]+=1
    if q[(a,a+d)]>2:
        z=True
        break
if z or cnt0>1:
    print(0)
elif cnt0==1 and t%2==0:
    print(0)

   
else:
    res=1
    for i in q:
        if i[0]==i[1]:
            res=res*1
        else:
            res=res*2
    print(res%mod)

Solution (Python):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
ans=[0]*(10**5+1)
flag=False
if n%2==0:
  for i in range(len(a)):
    if a[i]%2==0:
      flag=True
      break
    ans[a[i]]+=1
    if ans[a[i]]>2:
      flag=True
      break
else:
  for i in range(len(a)):
    if a[i]%2==1:
      flag=True
      break
    ans[a[i]]+=1
    if ans[0]>1:
      flag=True
      break
    if ans[a[i]]>2:
      flag=True
      break
if flag==True:
  print(0)
else:
  print(pow(2,(n//2),mod))

Solution (Python):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
ans=[0]*(10**5+1)
flag=False
if n%2==0:
  for i in range(len(a)):
    if a[i]%2==0:
      flag=True
      break
    ans[a[i]]+=1
    if ans[a[i]]>2:
      flag=True
      break
else:
  for i in range(len(a)):
    if a[i]%2==1:
      flag=True
      break
    ans[a[i]]+=1
    if ans[0]>1:
      flag=True
      break
    if ans[a[i]]>2:
      flag=True
      break
if flag==True:
  print(0)
else:
  print(pow(2,(n//2),mod))

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

Solution (Python):
from collections import Counter,defaultdict

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

if N%2 == 0:
    a = defaultdict(int)
    for i,j in zip(c.keys(),c.values()):
        a[i] = j
    
    for i in range(N//2):
        if a[i*2+1] != 2:
            print(0)
            exit()
    
    print(pow(2,N//2,int(1e9+7)))

else:
    a = defaultdict(int)
    for i,j in zip(c.keys(),c.values()):
        a[i] = j

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

    print(pow(2,N//2,int(1e9+7)))

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

ans = []
if N%2 == 0:
    for i in range(N):
        ans.append(2*(i//2)+1)
    if ans == a:
        print(pow(2,N//2,MOD))
    else:
        print(0)
else:
    for i in range(N):
        ans.append(2*((i+1)//2))
    if ans == a:
        print(pow(2,(N-1)//2,MOD))
    else:
        print(0)

Solution (Python):
from collections import Counter

N = int(input())
A = [0] + list(map(int, input().split()))
p = 10**9 + 7
l = Counter(A)

flag = True
for i in range(N%2 == 0,N,2):
  if l[i] != 2:
    flag = False
    break
if flag:
  print(pow(2,N//2,p))
else:
  print(0)

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())

    def check(L, n):
        
        if n % 2 == 0:
            for i in range(n):
                if (i % 2 == 0 and L[i] != i + 1) or (i % 2 == 1 and L[i] != i):
                    return False
        
        else:
            for i in range(n):
                if (i % 2 == 0 and L[i] != i) or (i % 2 == 1 and L[i] != i + 1):
                    return False
        return True

    
    n = ii()
    L = lmi()
    L.sort()
    if check(L, n):
        if n % 2 == 1:
            print(pow(2, (n - 1)//2, mod))
        else:
            print(pow(2, n//2, mod))
    else:
        print(0)


if __name__ == "__main__":
    main()

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

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

A = sorted(collections.Counter(a).most_common())

flg = True
ans = 1

if n % 2 == 0:
    
    if len(A) == n//2:
        for i in range(n//2):
            if A[i][0] == 1+i*2 and A[i][1] == 2:
                ans = ans * 2 % MOD
            else:
                flg = False
                break
    else:
        flg = False
else:
    
    if len(A) == n//2+1:
        for i in range(n//2+1):
            if i == 0:
                if A[i][0] == 0 and A[i][1] == 1:
                    pass
                else:
                    flg = False
                    break
            else:
                if A[i][0] == i*2 and A[i][1] == 2:
                    ans = ans * 2 % MOD
                else:
                    flg = False
                    break
    else:
        flg = False

if flg:
    print(ans)
else:
    print(0)

Solution (Python):

import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    A=list(map(int,input().split()))
    c=Counter(A)
    if N%2:
        if not (0 in c and c[0]==1):
            print(0)
            exit()
        for k in range(2,N,2):
            if not (k in c and c[k]==2):
                print(0)
                exit()
    else:
        for k in range(1,N,2):
            if not (k in c and c[k]==2):
                print(0)
                exit()
    print(pow(2,N//2,MOD))

if __name__ == '__main__':
    main()

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 and l.count(0)==0:
  print(2**(n//2)%mod)
elif not n % 2 == 0 and l.count(0) == 1 and len(set(l))-1==n//2:
  print(2**((n-1)//2)%mod)
else:
  print(0)

Solution (Python):

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

counters = Counter(A).items()

if N % 2 == 1:
    for k, v in counters:
        if k == 0:
            if v != 1:
                print(0)
                break
        else:
            if k % 2 != 0 or v != 2:
                print(0)
                break
    else:
        ans = pow(2, N // 2, mod)
        print(ans)
else:
    for k, v in counters:
        if k % 2 != 1 or v != 2:
            print(0)
            break
    else:
        ans = pow(2, N // 2, mod)
        print(ans)

Solution (Python):
import sys
from collections import defaultdict
MOD=10**9+7
N=int(input())
alist=list(map(int,input().split()))

adic=defaultdict(int)
for a in alist:
  adic[a]+=1


answer=1
if N%2==1:  
  for a,v in adic.items():
    
    if a==0:
      if v!=1:
        print(0)
        sys.exit(0)
    elif a%2==0:
      if v!=2:
        print(0)
        sys.exit(0)
      else:
        answer*=2
        answer%=MOD
    else:
      print(0)
      sys.exit(0)
  print(answer)
else:
  for a,v in adic.items():
    
    if a%2==0:
      print(0)
      sys.exit(0)
    else:
      if v==2:
        answer*=2
        answer%=MOD
      else:
        print(0)
        sys.exit(0)
  print(answer)

Solution (Python):
import collections

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
di = collections.Counter(A)
if N % 2 != 0:
    num_list = [int(i) for i in range(2, N, 2)]
    for num in num_list:
        if di[num] != 2:
            break
    else:
        if A.count(0) == 1:
            ans = (2 ** (N // 2)) % (10 ** 9 + 7)

else:
    num_list = [int(i) for i in range(1, N, 2)]
    for i in num_list:
        if di[i] != 2:
            break
    else:
        ans = (2 ** (N // 2)) % (10 ** 9 + 7)
print(ans)

Solution (Python):
import collections
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
c = collections.Counter(a)
cl = ""
if n%2 == 1:
	cl = "odd"
else:
	cl = "even"
ans = 0
flg = True
if cl == "odd":
	for i in c:
		if i%2 == 1:
			flg = False
		if i == 0:
			if c[i] != 1:
				flg = False
		else:
			if c[i] != 2:
				flg = False
else:
	for i in c:
		if i%2 == 2:
			flg = False
		if c[i] != 2:
			flg = False
if not (flg):
	print (ans)
	exit()
ans = 2**(n//2)%mod
print (ans)

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

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