program arc066c
    use,intrinsic :: iso_fortran_env
    implicit none
        integer(int64):: n,i
        integer(int64), allocatable:: a(:), cnt(:), cnt_pred(:)

        read*, n
        allocate(a(n))
        allocate(cnt(0:n), cnt_pred(0:n), source=0_8)
        read*, a(:)

        if (mod(n,2_8) == 0) then
            cnt_pred(1:n:2) = 2
        else
            cnt_pred(0) = 1
            cnt_pred(2:n:2) = 2
        end if

        do i=1,n
            cnt(a(i))=cnt(a(i))+1
        end do

        do i=1,n
            if (cnt(i) /= cnt_pred(i)) then
                print'(i0)', 0
                stop
            end if
        end do

        print'(i0)', iterative_square(2_8,n/2,10**9+7_8)

contains
function iterative_square(a,n,md) result(ret)
    use,intrinsic :: iso_fortran_env
    integer(int64):: a,n,i,md,mul
    integer(int64):: ret

    ret = 1
    mul = a
    do i=1,bit_size(n)
        if (btest(n,i-1)) ret = mod(ret*mul,md)
        mul=mod(mul*mul,md)
    end do
end function
end program arc066c