// 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;
// 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;
    }
    long ans = 1;
    foreach (i; 0 .. N)
    {
        foreach (x; 1 .. cnt1[i] + 1)
            ans *= x, ans %= MOD;
    }
    writeln(ans);

}
/// x^^n % m
T powmod(T = long)(T x, T n, T m = 10 ^^ 9 + 7)
{
    if (n < 1)
        return 1;
    if (n & 1)
        return x * powmod(x, n - 1, m) % m;
    return tmp = powmod(x, n / 2, m), tmp * tmp % m;
}
