// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
alias invmod=(long x,long n,long m=10^^9+7)=>powmod(x,m-2,m);alias powmod=(long x,long n,long m=10^^9+7)=>
std.math.powmod(cast(ulong) x,cast(ulong) n,cast(ulong) m);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto cnt1 = new long[](N);
    auto cnt2 = new long[](N);
    foreach (i; 0 .. N)
    {
        cnt1[abs(i - (N - 1 - i))]++;
        cnt2[A[i]]++;
    }
    if (zip(cnt1, cnt2).any!"a[0] != a[1]"())
    {
        writeln(0);
        return;
    }
    writeln((2) ^^ Mod(N / 2));

}

struct Mod
{
    alias T = long;
    T data, m;
    alias data this;
    this(T x, T m = 10 ^^ 9 + 7)
    {
        this.data = x;
        this.m = m;
    }

    Mod opBinary(string op, R)(R rhs)
    {
        static if (op == "-")
            return Mod((m + data - rhs) % m, m);
        static if (op == "^^")
            return Mod(std.math.powmod(cast(ulong) data, cast(ulong) rhs, cast(ulong) m), m);
        static if (op == "/")
            return Mod(data * std.math.powmod(cast(ulong) rhs, cast(ulong) m - 2, cast(ulong) m) % m,
                    m);
        return Mod(mixin("data " ~ op ~ " rhs") % m, m);
    }

    Mod opUnary(string op)()
    {
        static if (op == "-")
            return Mod((m + data - 1) % m, m);
        return Mod(mixin(op ~ "data") % m, m);
    }
}
