CodeEff/ECCO huggingface dataset:
# Original solution
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from functools import lru_cache
INF = float("inf")

MOD = 998244353  # type: int


def main():
    A, B, C, D = list(map(int, input().split()))

    @lru_cache(maxsize=None)
    def f(a, b):
        if a < A or b < B:
            return 0
        if a == A and b == B:
            return 1
        elif a == A:
            return pow(A, b-B, MOD)
        elif b == B:
            return pow(B, a-A, MOD)
        ans = (f(a-1, b)*b) % MOD
        ans += (f(a, b-1)*a) % MOD
        ans -= (f(a-1, b-1)*(a-1)*(b-1)) % MOD
        ans %= MOD
        return ans

    print((f(C, D)))

    return


if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from functools import lru_cache
INF = float("inf")

MOD = 998244353  # type: int


def main():
    A, B, C, D = list(map(int, input().split()))
    DP = [[1]*(D-B+1) for _ in range(C-A+1)]

    for i in range(C-A+1):
        for j in range(D-B+1):
            if i == j == 0:
                continue
            DP[i][j] = 0
            if 0 <= i-1:
                DP[i][j] += (DP[i-1][j]*(j+B)) % MOD
                DP[i][j] %= MOD
            if 0 <= j-1:
                DP[i][j] += (DP[i][j-1]*(i+A)) % MOD
                DP[i][j] %= MOD
            if 0 <= i-1 and 0 <= j-1:
                DP[i][j] -= (DP[i-1][j-1]*(i+A-1)*(j+B-1)) % MOD
                DP[i][j] %= MOD
            # print(i, j, DP[i][j])
    print((DP[-1][-1] % MOD))
    # print(DP)

    # @lru_cache(maxsize=None)
    # def f(a, b):
    #     if a < A or b < B:
    #         return 0
    #     if a == A and b == B:
    #         return 1
    #     elif a == A:
    #         return pow(A, b-B, MOD)
    #     elif b == B:
    #         return pow(B, a-A, MOD)
    #     ans = (f(a-1, b)*b) % MOD
    #     ans += (f(a, b-1)*a) % MOD
    #     ans -= (f(a-1, b-1)*(a-1)*(b-1)) % MOD
    #     ans %= MOD
    #     return ans

    # print(f(C, D))

    return


if __name__ == '__main__':
    main()
# Original solution
a,b,c,d=list(map(int,input().split()))
p=998244353
n=c-a+2
m=d-b+2
data=[[0]*(m)for i in range(n)]

data[1][1]=1

#print(data)

for i in range(1,n):
    gyou=a+i-1
    for j in range(1,m):
        retu=b+j-1
        if(i*j==1):
            continue
        data[i][j]=data[i-1][j]*retu+data[i][j-1]*gyou-data[i-1][j-1]*(gyou-1)*(retu-1)%p
        #print(gyou,retu,i,j,data[i][j])
#print(data)
print((data[n-1][m-1]%p))

# Optimized solution
a,b,c,d=list(map(int,input().split()))
p=998244353
n=c-a+2
m=d-b+2
data=[[0]*(m)for i in range(n)]

data[1][1]=1

#print(data)

for i in range(1,n):
    gyou=a+i-1
    for j in range(1,m):
        retu=b+j-1
        if(i*j==1):
            continue
        data[i][j]=(data[i-1][j]*retu%p)+(data[i][j-1]*gyou%p)-((data[i-1][j-1]*(gyou-1)%p)*(retu-1)%p)
        data[i][j]=data[i][j]%p
        #print(gyou,retu,i,j,data[i][j])
#print(data)
print((data[n-1][m-1]%p))
# Original solution
A,B,C=list(map(int,input().split()))

print((max(A,B,C)*9+A+B+C))

# Optimized solution
A,B,C=list(map(int,input().split()))

maxa=max(A,B,C)

print((maxa*9+A+B+C))
# Original solution
a,b,c = sorted(input().split())[::-1]
print((int(a+b)+int(c)))


# Optimized solution
A=sorted(map(int,input().split()))[::-1]
print((10*A[0]+A[1]+A[2]))
# Original solution
a, b, c = sorted(map(int, input().split()))

print((c*10 + b + a))

# Optimized solution
a, b, c = list(map(int, input().split()))

print((max(a, b, c)*9 + (a + b + c)))
# Original solution
a,b,c=list(map(int,input().split()))
if(a>=b):
    if(a>=c):
        print(((a*10)+b+c))
    else:
        print(((c*10)+a+b))
elif (b>=c):
    print((b * 10 + a + c))

# Optimized solution
a,b,c=sorted(map(int,input().split()))
print((c*10+a+b))
# Original solution
def big(a, b, c):
    if a>=b and a>=c:
        g = a
    elif b>=a and b>=c:
        g = b
    else:
        g = c

    return g


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

a, b, c = n[0], n[1], n[2]
g1, g2 = 0, 0

g1 = big(a, b, c)
if g1 == a:
    a = 0
elif g1 == b:
    b = 0
else:
    c = 0

g2 = big(a, b, c)
if g2 == a:
    a = 0
elif g2 == b:
    b = 0
else:
    c = 0

num = g1*10 + g2 + a + b + c

print(num)


# Optimized solution
s = input()
a,b,c = list(map(int, s.split(" ")))
l=[a,b,c]
l.sort(reverse=True)
m = l[0] * 10 + l[1] + l[2]
print(m)
# Original solution
l =[int(x) for x in input().split()]
l.sort(reverse=True)
print((int(int(l[0])*10 + int(l[1])+int(l[2]))))

# Optimized solution
a = [int(_) for _ in input().split()]
a.sort(reverse =True)
print((a[0]*10 + a[1]  +a[2]))
# Original solution
def LI(): return list(map(str, input().split()))


A = LI()

A.sort(reverse=True)
print((int(A[0] +A[1]) +int(A[2])))


# Optimized solution
def LI(): return list(map(int, input().split()))


A,B,C = LI()
max_value = max([A*10+B+C,A+B*10+C,A+B+C*10])

print(max_value)
# Original solution
from itertools import permutations
from copy import copy

choices = list(map(int, input().split()))
combs = permutations(choices, 2)

res = 0

for comb in combs:
    left = copy(choices)
    for num in comb:
        left.remove(num)
    right = int(str(comb[0]) + str(comb[1]))
    total = left[0] + right
    if total > res:
        res = total

print(res)


# Optimized solution
choices = list(map(int, input().split()))
choices.sort(reverse=True)
print((int(str(choices[0]) + str(choices[1])) + choices[2]))
# Original solution
a,b,c = sorted(map(int, input().split()),reverse=True)

print((a*10+b+c))


# Optimized solution
*A,= list(map(int, input().split()))

A.sort(reverse=True)

print((A[0]*10+A[1]+A[2]))
# Original solution
A,B,C=list(map(int,input().split()))
print((max([A*10+B+C,A+B*10+C,A+B+C*10])))

# Optimized solution
A=list(map(int,input().split()))
A.sort()
print((A[0]+A[1]+10*A[2]))
# Original solution
def nl(): return list(map(int, input().split()))
# print('Yes' if a else 'No')

arr = nl()
print((max(arr) * 9 + sum(arr)))

# Optimized solution
ary = list(map(int, input().split()))
ans = sum(ary) + 9 * max(ary)
print(ans)
# Original solution
A,B,C=sorted(map(int,input().split()))
print((10*C+B+A))

# Optimized solution
ABC=list(map(int,input().split()))
print((sum(ABC)+max(ABC)*9))
# Original solution
a, b, c = sorted(map(int, input().split()))
print((c*10+a+b))

# Optimized solution
*x,=list(map(int,input().split()));print((sum(x)+max(x)*9))
# Original solution
a,b,c=sorted(map(int,input().split()))
print((10*c+b+a))

# Optimized solution
a,b,c=sorted(list(map(int,input().split())))
print((c*10+b+a))
# Original solution
S = input().split()
S.sort(reverse=True)
print((10 * int(S[0]) + int(S[1]) + int(S[2])))


# Optimized solution
A, B, C = sorted(map(int, input().split()))
print((C * 10 + A + B))
# Original solution
def func():
    A, B, C = list(map(str, input().split()))
    cand1 = int(A + B) + int(C)
    cand2 = int(B + C) + int(A)
    cand3 = int(A + C) + int(B)
    cand4 = int(B + A) + int(C)
    cand5 = int(C + B) + int(A)
    cand6 = int(C + A) + int(B)
    print((max(cand1, cand2, cand3, cand4, cand5, cand6)))


if __name__ == '__main__':
    func()


# Optimized solution
def func():
    A, B, C = list(map(int, input().split()))
    cand1 = A * 10 + B + C
    cand2 = B * 10 + A + C
    cand3 = C * 10 + A + B
    print((max(cand1, cand2, cand3)))


if __name__ == '__main__':
    func()
# Original solution
l = sorted(list(map(int, input().split())))

print((l[2] * 10 + l[1] + l[0]))

# Optimized solution
l = sorted(list(map(int, input().split())), reverse = True)
print((l[0] * 10 + l[1] + l[2]))
# Original solution
*l,=list(map(int,input().split()))
l.sort()
print((l[2]*10+l[1]+l[0]))

# Optimized solution
l=sorted(map(int,input().split()))
print((l[2]*10+sum(l[:2])))
# Original solution
num = list(map(int, input().split()))
num.sort(reverse=True)
print((10*num[0] + num[1] + num[2]))

# Optimized solution
l = list(input().split())
l.sort(reverse=True)
print((int(''.join(l[:2])) + int(l[2])))
# Original solution
li = list(map(int,input().split()))
li = sorted(li, reverse=True)
print((10*li[0]+li[1]+li[2]))

# Optimized solution
L = sorted(list(map(int, input().split())))

print((10*L[2]+L[1]+L[0]))
# Original solution
X = list(map(int, input().split()))
S = sorted(X, reverse=True)
X, Y = S[0] * 10 + S[1], S[2]
print((X + Y))

# Optimized solution
A = list(map(int, input().split()))
A.sort(reverse=True)
print((A[0] * 10 + A[1] + A[2]))
# Original solution
A=list(map(int,input().split()))
A=sorted(A,reverse=True)
ans=10*A[0]+A[1]+A[2]
print(ans)

# Optimized solution
A=list(map(int,input().split()))
ans=sum(A)+9*max(A)
print(ans)
# Original solution
a = sorted(list(map(int, input().split())),reverse=True)
print((a[0]*10+a[1]+a[2]))


# Optimized solution
a = sorted(list(map(int, input().split())),reverse=True)
print((sum(a)+a[0]*9))
# Original solution
def getN():
    return int(eval(input()))

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

a,b,c = getlist()
m = max([a,b,c])
print((10*m + a+ b+ c -m))

# Optimized solution
a, b, c = list(map(int, input().split()))

big = max([a,b,c])

print((sum([a,b,c]) + 9*big))
# Original solution
a,b,c=list(map(int,input().split()))
if b<=c:
    d=b
    b=c
    c=d
if a<=b:
    d=a
    a=b
    b=d
if b<=c:
    d=b
    b=c
    c=d

print((10*a+b+c))
    

# Optimized solution
A,B,C=sorted(map(int,input().split()))
print((10*C+B+A))
# Original solution
num = list(map(int,input().split()))
num.sort(reverse=True)
print((num[0]*10+num[1]+num[2]))

# Optimized solution
N = list(map(int,input().split()))
N.sort()
print((N[2]*10+N[1]+N[0]))
# Original solution
import itertools, copy

n = input().split()

ans = 0
for p0, p1 in itertools.permutations(n, 2):
    n_ = copy.copy(n)
    n_.remove(p0)
    n_.remove(p1)
    
    total = int(''.join([p0, p1])) + int(n_[0])
    ans = max(ans, total)

print(ans)

# Optimized solution
n = list(map(int, input().split()))

nmax = max(n)
n.remove(nmax)
ans = nmax * 10 + sum(n) 
print(ans)
# Original solution
x,y,z = list(map(int,input().split()))
print((max(x,y,z) * 10 + x + y + z - max(x,y,z)))

# Optimized solution
l=list(map(int,input().split()));print((max(l)*9+sum(l)))
# Original solution
A = sorted([int(i) for i in input().split()])

print((A[2]*10 + sum(A[:2])))

# Optimized solution
A, B, C = list(map(int, input().split()))

x = A * 10 + B + C
y = A + 10 * B + C
z = A + B + 10 * C
print((max(x, y, z)))
# Original solution
a = list(map(int, input().split()))
a.sort()
print((a[2]*10+a[1]+a[0]))

# Optimized solution
a = list(map(int,input().split()))
print((sum(a)+max(a)*9))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
def valid():
    b = list(range((n+1)&1, n+1, 2))
    for i in range(len(b)-1, -1, -1):
        b.insert(i, b[i])
    if b[0] == 0:
        b = b[1:]
    return list(sorted(a)) == b
ans,mod = 1,10**9+7
for i in range(n//2):
    ans = (ans * 2) % mod
print((ans if valid() else 0))

# Optimized solution
n=int(eval(input()))
a=list(sorted(map(int,input().split())))
def valid():
    cur=(n+1)&1
    for i in range(n):
        if n&1==0 and i&1==0 and i>0:
            cur+=2
        if n&1==1 and i&1==1:
            cur+=2
        if a[i] != cur: return False
    return True
print((2**(n//2)%(10**9+7) if valid() else 0))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

if n % 2 == 0:
    for i in range(n//2):
        if a.count(2*i + 1) != 2:
            print((0))
            exit()
else:
    if a.count(0) != 1:
        print((0))
        exit()
    for i in range(1,n//2+1):
        if a.count(2*i) != 2:
            print((0))
            exit()
    
print((2**(n//2) % (10**9+7)))

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
d = 0

if n % 2 == 0:
    for i in range(n//2):
        d += (2*i + 1) * 2
    if d != sum(a):
        print((0))
        exit()
else:    
    for i in range(1, n//2+1):
        d += 4 * i
    if d != sum(a):
        print((0))
        exit()

print((2**(n//2) % (10**9+7)))
# Original solution
from collections import Counter


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


# Optimized solution
from collections import Counter


N = int(eval(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)
# Original solution
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n = int(eval(input()))
    a = list(map(int, input().split()))
    if(n % 2 == 0):
        for i in range(1, n, 2):
            if(a.count(i) != 2):
                print((0))
                exit(0)
        print((2**(n//2)))
        exit(0)
    for i in range(0, n, 2):
        if(i == 0 and a.count(i) != 1):
            print((0))
            exit(0)
        elif(i != 0 and a.count(i) != 2):
            print((0))
            exit(0)
    print((2**(n//2)))


if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()
# Original solution

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

ans = 1
if N % 2 == 1 and A.count(0) != 1:
    ans = 0

if N % 2 == 1:
    A.remove(0)
    
c = -1
if N % 2 == 0:
    c = 1
else:
    c = 2

for i in range(c, N, 2):
    if A.count(i) != 2:
        ans = 0
    else:
        ans *= 2
        A.remove(i)
        A.remove(i)

if len(A) != 0:
    ans = 0

print((ans % 1000000007))



# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))

ans = 1
A.sort()
if N % 2 == 1 and not A.count(0) == 1:
    ans = 0

s = -1
if N % 2 == 1:
    A.remove(0)
    s = 2
else:
    s = 1

for i in range(0, len(A), 2):
    if A[i] == A[i + 1] == s:
        ans *= 2
    else:
        ans = 0
    s += 2
    
print((ans % 1000000007))
# Original solution
import collections
n = int(eval(input()))
a = list(map(int, input().split()))
dd = collections.defaultdict(int)
correct = []
if n % 2 == 1:
    correct.append(0)
    for i in range((n - 1) // 2):
        correct.append(2 * i + 2)
        correct.append(2 * i + 2)
else:
    correct.append(1)
    correct.append(1)
    for i in range(n // 2):
        correct.append(2 * i + 3)
        correct.append(2 * i + 3)
a.sort()
correct.sort()
for i in range(n):
    if a[i] != correct[i]:
        print((0))
        exit()
for i in range(n):
    dd[str(a[i])] += 1
ans = 1
for k in list(dd.keys()):
    if dd[k] >= 2:
        ans *= 2
        ans %= 10 ** 9 + 7
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
a = sorted(a)
if n % 2 == 1:
    if a[0] != 0:
        print((0))
        exit()
    for i in range(1, n, 2):
        if a[i] != a[i + 1] or a[i] != i + 1:
            print((0))
            exit()
else:
    for i in range(0, n, 2):
        if a[i] != a[i + 1] or a[i] != i + 1:
            print((0))
            exit()
print((2 ** (n // 2) % (10 ** 9 + 7)))
# Original solution
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    MOD = 10**9 + 7
    from collections import Counter
    A_c = Counter(A)
    for k,v in A_c.items():
        if k == 0 and v != 1:
            return print(0)
        elif k != 0 and v != 2:
            return print(0)
    else:
        print(2 ** (N//2) % MOD)
if __name__ == '__main__':
    main()


# Optimized solution
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    MOD = 10**9 + 7
    from collections import Counter
    c = Counter(A)
    # print(c)
    for k, v in c.items():
        if k != 0 and v != 2:
            return print(0)
    if N & 1 and c[0] != 1:
        return print(0)

    if N & 1:
        ma = max(A)//2
    else:
        ma = (max(A) + 1)//2
    print(pow(2, ma, MOD))


if __name__ == '__main__':
    main()
# Original solution
from collections import Counter

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

cntA = Counter(A)

if N % 2 == 0:
    for i in range(1, N, 2):
        if cntA[i] != 2:
            print((0))
            exit()
        cntA[i] = 0
    if max(cntA.values()) > 0:
        print((0))
        exit()
    print((pow(2, N // 2, MOD)))
else:
    for i in range(2, N, 2):
        if cntA[i] != 2:
            print((0))
            exit()
        cntA[i] = 0
    if cntA[0] != 1:
        print((0))
        exit()
    cntA[0] = 0
    if max(cntA.values()) > 0:
        print((0))
        exit()
    print((pow(2, N // 2, MOD)))

# Optimized solution
from collections import Counter

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

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

print((pow(2, N // 2, 10**9 + 7)))
# Original solution
import sys
n = int(eval(input()))
a = list(map(int, input().split(' ')))

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

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

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(eval(input()))
    A = sorted(list(map(int, input().split())))

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


if __name__ == '__main__':
    resolve()


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(eval(input()))
    A = sorted(list(map(int, input().split())))
    if n % 2 == 0:
        num = 1
        for i in range(0, n - 1, 2):
            if A[i] != num or A[i + 1] != num:
                print((0))
                exit()
            num += 2
    else:
        if A[0] != 0:
            print((0))
            exit()
        num = 2
        for i in range(1, n - 1, 2):
            if A[i] != num or A[i + 1] != num:
                print((0))
                exit()
            num += 2

    res = pow(2, n // 2, mod)
    print((res % mod))


if __name__ == '__main__':
    resolve()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

mod = 10 ** 9 + 7
ans = 0

if N % 2 == 0:
    for i in range(1, N, 2):
        if A.count(i) != 2:
            print((0))
            exit()
    print((2 ** (N // 2) % mod))
else:
    for i in range(2, N, 2):
        if A.count(i) != 2:
            print((0))
            exit()
    if A.count(0) != 1:
        print((0))
        exit()
    print((2 ** (N // 2) % mod))


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

if A == B:
    print((2 ** ( N // 2) % mod))
else:
    print((0))
# Original solution
a = int(eval(input()))
b = list(map(int, input().split()))
b.sort()
c = 1 if a % 2 == 0 else 0
for i in range(a):
    if (a % 2) ^ (i % 2) == 0 and i != 0:
        c += 2
    if b[i] != c:
        print((0))
        exit()
print(((2 ** (a // 2)) % (10 ** 9 + 7)))


# Optimized solution
a = int(eval(input()))
b = list(map(int, input().split()))
b.sort()
if a % 2 == 0:
    c = 1
    for i in range(len(b)):
        if i > 0 and i % 2 == 0:
            c += 2
        if b[i] != c:
            print((0))
            exit()
    print(((2 ** (a // 2)) % (10 ** 9 + 7)))
else:
    c = 0
    for i in range(len(b)):
        if i > 0 and i % 2 == 1:
            c += 2
        if b[i] != c:
            print((0))
            exit()
    print(((2 ** ((a-1) // 2)) % (10 ** 9 + 7)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
if N & 1:
    if A.count(0) == 1:
        for i in range(2,N,2):
            if A.count(i)!=2:
                print((0))
                exit()
    else:
        print((0))
        exit()
else:
    for i in range(1, N, 2):
        if A.count(i) != 2:
            print((0))
            exit()
print((pow(2, N//2, 10**9+7)))


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