stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<cstdio>

#include<stack>

#include<queue>

#include<map>

#include<cstring>



using namespace std;



const int MAX=1e5+10;



int a[MAX];

int p[MAX];



long long mod_exp(int b){

	long long res,t;

	res=1;

	t=2;

	while(b){

		if(b&1){

			res=res*t%1000000007;

		}

		t=t*t%1000000007;

		b>>=1;

	}

	return res;

}



int main(){

	int n;

	cin>>n;

	memset(p,0,sizeof(p));

	for(int i=0;i<n;i++){

		scanf("%d",&a[i]);

		p[a[i]]++;

	}

	int cnt=0;

	bool flag=true;

	for(int i=0;i<n;i++){

		if((n+a[i]+1)%2!=0||(n-a[i]+1)%2!=0||(p[0]!=1&&n%2==1)||(p[a[i]]!=2&&a[i]!=0)){

			cout<<"0"<<endl;

			flag=false;

			break;

		}

		if(p[i]==2)

		cnt++;

	}

	if(flag)

	cout<<mod_exp(cnt)<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 7.311334131081006x):
#include<cstdio>

#include<algorithm>

using namespace std;

int result(int a,int b,int m)

{

	long long  d=1,t=a;

	while(b)

	{

		if(b&1)

		d=(d*t)%m;

		b/=2;

		t=(t*t)%m;

	}

	return d;

}                        

int a[100010];

int main()

{

	int n;

	while(scanf("%d",&n)!=EOF)

	{

		for(int i = 1; i <= n; i++)

		{

			scanf("%d",&a[i]);

			

		}

		sort(a+1,a+n+1);

		int f=1;

		if(n%2==1)

		{

			for(int i = 1; i <= n; i++)

			{

				if(i%2==0)

				{

					if(a[i]!=i)

					{

						f=0;break;

					}

				}

				else

				{

					if(a[i]!=i-1)

					{

						f=0;break;

					}

				}

			}	

		}

		else

		{

			for(int i = 1; i <= n; i++)

			{

				if(i%2==0)

				{

					if(a[i]!=i-1)

					{

						f=0;break;

					}

				}

				else

				{

					if(a[i]!=i)

					{

						f=0;break;

					}

				}

			}	

		}

		if(f==0)

		printf("0\n");

		else

		{

			printf("%d\n",result(2,n/2,1000000007));

		}

	}

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

#define MOD 1000000007

#define MAXN 100006

typedef long long LL;

int a[MAXN];

LL Quick(LL a,LL b,LL c)

{

	LL ans=1;

	a=a%c;

	while(b)

	{

		if(b&1)

			ans=(ans*a)%c;

		a=(a*a)%c;

		b/=2;

	}

	return ans;

}

int main()

{

	int n;

	while(~scanf("%d",&n))

	{

		int flag1=0,flag2=0;

		memset(a,0,sizeof(a));

		for(int i=0;i<n;i++)

		{

			int t;

			scanf("%d",&t);

			a[t]++;

			if(t>=n)

				flag1=1;

			if(n&1)

			{

				if(t&1)

					flag2=1;

			}

				

			else

			{

				if(!(t&1))

					flag2=1;

			}

		}

		if(flag1)

		{

			printf("0\n");

			continue;

		}

		if(flag2)

		{

			printf("0\n");

			continue;

		}

		if(n&1)

		{

			if(a[0]!=1)

			{

				printf("0\n");

				continue;

			}

		}

		else

		{

			if(a[0]!=0)

			{

				printf("0\n");

				continue;

			}

		}

		int cnt=1;

		LL m=n/2;

		LL sum;

		if(n&1)

		{

			for(int i=2;i<n;i+=2)

			{

				if(a[i]!=2)

				{

					cnt=0;

					break;

				}

					

			}

			if(cnt)

			{

				sum=Quick(2,m,MOD);

				printf("%lld\n",sum);

			}	

			else

			{

				printf("0\n");

				continue;

			}

		}

		else

		{

			for(int i=1;i<n;i+=2)

			{

				if(a[i]!=2)

				{

					cnt=0;

					break;

				}

					

			}

			if(cnt)

			{

				sum=Quick(2,m,MOD);

				printf("%lld\n",sum);

			}	

			else

			{

				printf("0\n");

				continue;

			}

		}

	}

	return 0;	

}

// Faster C++ solution for the same problem (measured speedup: 3.081860848349332x):
#include<cstdio>

#include<algorithm>

using namespace std;

int result(int a,int b,int m)

{

	long long  d=1,t=a;

	while(b)

	{

		if(b&1)

		d=(d*t)%m;

		b/=2;

		t=(t*t)%m;

	}

	return d;

}                        

int a[100010];

int main()

{

	int n;

	while(scanf("%d",&n)!=EOF)

	{

		for(int i = 1; i <= n; i++)

		{

			scanf("%d",&a[i]);

			

		}

		sort(a+1,a+n+1);

		int f=1;

		if(n%2==1)

		{

			for(int i = 1; i <= n; i++)

			{

				if(i%2==0)

				{

					if(a[i]!=i)

					{

						f=0;break;

					}

				}

				else

				{

					if(a[i]!=i-1)

					{

						f=0;break;

					}

				}

			}	

		}

		else

		{

			for(int i = 1; i <= n; i++)

			{

				if(i%2==0)

				{

					if(a[i]!=i-1)

					{

						f=0;break;

					}

				}

				else

				{

					if(a[i]!=i)

					{

						f=0;break;

					}

				}

			}	

		}

		if(f==0)

		printf("0\n");

		else

		{

			printf("%d\n",result(2,n/2,1000000007));

		}

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<cstdio>

#include<stack>

#include<queue>

#include<map>

#include<cstring>



using namespace std;



const int MAX=1e5+10;



int a[MAX];

int p[MAX];



long long mod_exp(int b){

	long long res,t;

	res=1;

	t=2;

	while(b){

		if(b&1){

			res=res*t%1000000007;

		}

		t=t*t%1000000007;

		b>>=1;

	}

	return res;

}



int main(){

	int n;

	cin>>n;

	memset(p,0,sizeof(p));

	for(int i=0;i<n;i++){

		scanf("%d",&a[i]);

		p[a[i]]++;

	}

	int cnt=0;

	bool flag=true;

	for(int i=0;i<n;i++){

		if((n+a[i]+1)%2!=0||(n-a[i]+1)%2!=0||(p[0]!=1&&n%2==1)||(p[a[i]]!=2&&a[i]!=0)){

			cout<<"0"<<endl;

			flag=false;

			break;

		}

		if(p[i]==2)

		cnt++;

	}

	if(flag)

	cout<<mod_exp(cnt)<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3832645612550725x):
#include <iostream>

#include <cmath>

#include <stdio.h>

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <cstring>



using namespace std;



#define f first

#define s second

#define pb push_back

#define mp make_pair

#define ll long long

#define pii pair < int, int >

#define pll pair < long long, long long>

#define ull unsigned long long

#define vi vector < int >

#define vll vector < long long >

#define sz(a) (int)a.size()

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

#define all(a) a.begin(), a.end()

#define sqr(x) ((x) * (x))

#define fname "searching"



const int inf = (int)1e9;

const ll INF = (ll)1e18;

const double eps = 1e-9;

const double pi = acos(-1.0);

const int mod = (int)1e9 + 7;



int n;

int a[100100];

int ans;



int solve(){

    cin >> n;

    for(int i = 0; i < n; ++i) cin >> a[i];

    sort(a, a + n);

    if(a[0] != (n % 2 == 0)) return 0;

    int st = n % 2 == 0 ? 2 : 1;

    for(int i = n % 2, st = 2 - !(n % 2); i < n; i += 2, st += 2){

        if(a[i] == st && a[i + 1] == st) continue;

        else return 0;

    }

    

    ans = 1;

    for(int i = 0; i < n / 2; ++i){

        ans *= 2;

        ans %= mod;

    }

    return ans;

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    cout << solve() << "\n";

    

    return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

using namespace std;



long long con=1000000007,a[100070],cnt[100070],fac[100050];



long long fact(long long n)

{

    if(n==0)

    {

        return 1;

    }

    long long mul=1,i;



    mul=fac[n-1]*n;

    mul=mul%con;



    return mul;

}



int main()

{



    long long n,i,ans=1;



    for(i=0; i<100050; i++)

    {

        fac[i]=fact(i);

    }

    scanf("%lld",&n);



    for(i=0; i<n; i++)

    {

        scanf("%lld",&a[i]);

        cnt[a[i]]++;

    }



    for(i=1;i<100050; i++)

    {

        if(cnt[i]%2!=0)

        {

            printf("0");

            return 0;

        }





        ans*=fac[cnt[i]];

        ans=ans%con;

    }



    printf("%lld",ans);

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 3.309547338159773x):
#include <iostream>

#include <cmath>

#include <stdio.h>

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <cstring>



using namespace std;



#define f first

#define s second

#define pb push_back

#define mp make_pair

#define ll long long

#define pii pair < int, int >

#define pll pair < long long, long long>

#define ull unsigned long long

#define vi vector < int >

#define vll vector < long long >

#define sz(a) (int)a.size()

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

#define all(a) a.begin(), a.end()

#define sqr(x) ((x) * (x))

#define fname "searching"



const int inf = (int)1e9;

const ll INF = (ll)1e18;

const double eps = 1e-9;

const double pi = acos(-1.0);

const int mod = (int)1e9 + 7;



int n;

int a[100100];

int ans;



int solve(){

    cin >> n;

    for(int i = 0; i < n; ++i) cin >> a[i];

    sort(a, a + n);

    if(a[0] != (n % 2 == 0)) return 0;

    int st = n % 2 == 0 ? 2 : 1;

    for(int i = n % 2, st = 2 - !(n % 2); i < n; i += 2, st += 2){

        if(a[i] == st && a[i + 1] == st) continue;

        else return 0;

    }

    

    ans = 1;

    for(int i = 0; i < n / 2; ++i){

        ans *= 2;

        ans %= mod;

    }

    return ans;

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    cout << solve() << "\n";

    

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<cstdio>

#include<stack>

#include<queue>

#include<map>

#include<cstring>



using namespace std;



const int MAX=1e5+10;



int a[MAX];

int p[MAX];



long long mod_exp(int b){

	long long res,t;

	res=1;

	t=2;

	while(b){

		if(b&1){

			res=res*t%1000000007;

		}

		t=t*t%1000000007;

		b>>=1;

	}

	return res;

}



int main(){

	int n;

	cin>>n;

	memset(p,0,sizeof(p));

	for(int i=0;i<n;i++){

		scanf("%d",&a[i]);

		p[a[i]]++;

	}

	int cnt=0;

	bool flag=true;

	for(int i=0;i<n;i++){

		if((n+a[i]+1)%2!=0||(n-a[i]+1)%2!=0||(p[0]!=1&&n%2==1)||(p[a[i]]!=2&&a[i]!=0)){

			cout<<"0"<<endl;

			flag=false;

			break;

		}

		if(p[i]==2)

		cnt++;

	}

	if(flag)

	cout<<mod_exp(cnt)<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3860849589037618x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int Max=1e5+10;

const int Mod=1e9+7;

int a[Max];

int cnt[Max];

int main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    int n;

    cin>>n;

    ll sum=0;

    for(int i=1;i<=n;i++){

        cin>>a[i];

        cnt[a[i]]++;

    }

    bool flag=1;

    ll ans=1;

    if(n&1){

        if(cnt[0]!=1){

            flag=0;

        }

        for(int i=2;i<=n-1;i+=2){

            if(cnt[i]!=2){

                flag=0;

                break;

            }

        }

        for(int i=1;i<=n;i+=2){

            if(cnt[i]){

                flag=0;

                break;

            }

        }

    }else{

        for(int i=1;i<=n-1;i+=2){

            if(cnt[i]!=2){

                flag=0;

                break;

            }

        }

        for(int i=0;i<=n;i+=2){

            if(cnt[i]){

                flag=0;

                break;

            }

        }

    }

    if(flag){

        for(int i=1;i<=n/2;i++){

            ans=ans*2;

            ans%=Mod;

        }

    }else{

        ans=0;

    }

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

using namespace std;



long long con=1000000007,a[100070],cnt[100070],fac[100050];



long long fact(long long n)

{

    if(n==0)

    {

        return 1;

    }

    long long mul=1,i;



    mul=fac[n-1]*n;

    mul=mul%con;



    return mul;

}



int main()

{



    long long n,i,ans=1;



    for(i=0; i<100050; i++)

    {

        fac[i]=fact(i);

    }

    scanf("%lld",&n);



    for(i=0; i<n; i++)

    {

        scanf("%lld",&a[i]);

        cnt[a[i]]++;

    }



    for(i=1;i<100050; i++)

    {

        if(cnt[i]%2!=0)

        {

            printf("0");

            return 0;

        }





        ans*=fac[cnt[i]];

        ans=ans%con;

    }



    printf("%lld",ans);

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 3.316295316668166x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int Max=1e5+10;

const int Mod=1e9+7;

int a[Max];

int cnt[Max];

int main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    int n;

    cin>>n;

    ll sum=0;

    for(int i=1;i<=n;i++){

        cin>>a[i];

        cnt[a[i]]++;

    }

    bool flag=1;

    ll ans=1;

    if(n&1){

        if(cnt[0]!=1){

            flag=0;

        }

        for(int i=2;i<=n-1;i+=2){

            if(cnt[i]!=2){

                flag=0;

                break;

            }

        }

        for(int i=1;i<=n;i+=2){

            if(cnt[i]){

                flag=0;

                break;

            }

        }

    }else{

        for(int i=1;i<=n-1;i+=2){

            if(cnt[i]!=2){

                flag=0;

                break;

            }

        }

        for(int i=0;i<=n;i+=2){

            if(cnt[i]){

                flag=0;

                break;

            }

        }

    }

    if(flag){

        for(int i=1;i<=n/2;i++){

            ans=ans*2;

            ans%=Mod;

        }

    }else{

        ans=0;

    }

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<cstdio>

#include<stack>

#include<queue>

#include<map>

#include<cstring>



using namespace std;



const int MAX=1e5+10;



int a[MAX];

int p[MAX];



long long mod_exp(int b){

	long long res,t;

	res=1;

	t=2;

	while(b){

		if(b&1){

			res=res*t%1000000007;

		}

		t=t*t%1000000007;

		b>>=1;

	}

	return res;

}



int main(){

	int n;

	cin>>n;

	memset(p,0,sizeof(p));

	for(int i=0;i<n;i++){

		scanf("%d",&a[i]);

		p[a[i]]++;

	}

	int cnt=0;

	bool flag=true;

	for(int i=0;i<n;i++){

		if((n+a[i]+1)%2!=0||(n-a[i]+1)%2!=0||(p[0]!=1&&n%2==1)||(p[a[i]]!=2&&a[i]!=0)){

			cout<<"0"<<endl;

			flag=false;

			break;

		}

		if(p[i]==2)

		cnt++;

	}

	if(flag)

	cout<<mod_exp(cnt)<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3985503251047715x):
#include<cstdio>

#include<iostream>

#include<map>

#include<cstring>

using namespace std;

#define ll long long

ll n;

map<ll,ll>q;

map<ll,ll>::iterator it;

ll mod=1e9+7;

ll  modl(ll a, ll b, ll c)

{

    ll res, t;

    res = 1 % c;

    t = a % c;

    while (b){

        if (b & 1){

            res = res * t % c;

        }

        t = t * t % c;

        b >>= 1;

    }

    return res;

}

int main()

{

    q.clear();

    cin>>n;

    for(int i=1;i<=n;i++)

    {

        ll num;

        cin>>num;

        q[num]++;

    }

    if(q[0]>1)

    {

        cout<<"0"<<endl;

    }

    else if(q[0]==1||q[0]==0)

    {

        int num=0;

        for(it=q.begin();it!=q.end();it++)

        {

            if(it->second==2)

            {

                num++;

            }

            else if(it->second>2)

            {

                cout<<"0"<<endl;

                return 0;

            }

        }

        num%=mod;

        cout<<modl(2,num,mod)%mod<<endl;

    }

    return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

using namespace std;



long long con=1000000007,a[100070],cnt[100070],fac[100050];



long long fact(long long n)

{

    if(n==0)

    {

        return 1;

    }

    long long mul=1,i;



    mul=fac[n-1]*n;

    mul=mul%con;



    return mul;

}



int main()

{



    long long n,i,ans=1;



    for(i=0; i<100050; i++)

    {

        fac[i]=fact(i);

    }

    scanf("%lld",&n);



    for(i=0; i<n; i++)

    {

        scanf("%lld",&a[i]);

        cnt[a[i]]++;

    }



    for(i=1;i<100050; i++)

    {

        if(cnt[i]%2!=0)

        {

            printf("0");

            return 0;

        }





        ans*=fac[cnt[i]];

        ans=ans%con;

    }



    printf("%lld",ans);

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 3.3461194881862357x):
#include<cstdio>

#include<iostream>

#include<map>

#include<cstring>

using namespace std;

#define ll long long

ll n;

map<ll,ll>q;

map<ll,ll>::iterator it;

ll mod=1e9+7;

ll  modl(ll a, ll b, ll c)

{

    ll res, t;

    res = 1 % c;

    t = a % c;

    while (b){

        if (b & 1){

            res = res * t % c;

        }

        t = t * t % c;

        b >>= 1;

    }

    return res;

}

int main()

{

    q.clear();

    cin>>n;

    for(int i=1;i<=n;i++)

    {

        ll num;

        cin>>num;

        q[num]++;

    }

    if(q[0]>1)

    {

        cout<<"0"<<endl;

    }

    else if(q[0]==1||q[0]==0)

    {

        int num=0;

        for(it=q.begin();it!=q.end();it++)

        {

            if(it->second==2)

            {

                num++;

            }

            else if(it->second>2)

            {

                cout<<"0"<<endl;

                return 0;

            }

        }

        num%=mod;

        cout<<modl(2,num,mod)%mod<<endl;

    }

    return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

using namespace std;



long long con=1000000007,a[100070],cnt[100070],fac[100050];



long long fact(long long n)

{

    if(n==0)

    {

        return 1;

    }

    long long mul=1,i;



    mul=fac[n-1]*n;

    mul=mul%con;



    return mul;

}



int main()

{



    long long n,i,ans=1;



    for(i=0; i<100050; i++)

    {

        fac[i]=fact(i);

    }

    scanf("%lld",&n);



    for(i=0; i<n; i++)

    {

        scanf("%lld",&a[i]);

        cnt[a[i]]++;

    }



    for(i=1;i<100050; i++)

    {

        if(cnt[i]%2!=0)

        {

            printf("0");

            return 0;

        }





        ans*=fac[cnt[i]];

        ans=ans%con;

    }



    printf("%lld",ans);

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 2.385931948497745x):
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cstdio>

#include <algorithm>

#include <cmath>

#include <iomanip>

#include <vector>

using namespace std;

const int maxn = 1e5+100;

const int MOD = 1e9+7;

const double Pi = 3.141592654;

typedef long long ll;

typedef unsigned long long ull;





int main()

{

    int n;

    cin >> n;

    int a[maxn];

    int vis[maxn];

    int st;

    ll ans = 1;

    memset(vis, 0, sizeof(vis));

    for(int i=1 ; i<=n ; ++i)

    {

        cin >> a[i];

        vis[a[i]] ++;

    }

    if(!(n%2))//even

    {

        if(vis[0])

        {

            cout << 0 << endl;

            return 0;

        }

        for(int i=1 ; i<=n ; i+=2)

        {

            ans = (ans%MOD)*2%MOD;

            if(vis[i] != 2)

        {

            cout << 0 << endl;

            return 0;

        }

        }

    }

    else

    {

        if(vis[0] != 1)

        {

            cout << 0 << endl;

            return 0;

        }

        for(int i=2 ; i<=n ; i+=2)

        {

            ans = (ans%MOD)*2%MOD;

            if(vis[i] != 2)

        {

            cout << 0 << endl;

            return 0;

        }

        }

    }

    cout << ans << endl;



}



//9(4(7(1)(2))(3(6)(8)))(5(10)(11(12)))
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<algorithm>

#include<cstdio>

#include<stack>

#include<queue>

#include<map>

#include<cstring>



using namespace std;



const int MAX=1e5+10;



int a[MAX];

int p[MAX];



long long mod_exp(int b){

	long long res,t;

	res=1;

	t=2;

	while(b){

		if(b&1){

			res=res*t%1000000007;

		}

		t=t*t%1000000007;

		b>>=1;

	}

	return res;

}



int main(){

	int n;

	cin>>n;

	memset(p,0,sizeof(p));

	for(int i=0;i<n;i++){

		scanf("%d",&a[i]);

		p[a[i]]++;

	}

	int cnt=0;

	bool flag=true;

	for(int i=0;i<n;i++){

		if((n+a[i]+1)%2!=0||(n-a[i]+1)%2!=0||(p[0]!=1&&n%2==1)||(p[a[i]]!=2&&a[i]!=0)){

			cout<<"0"<<endl;

			flag=false;

			break;

		}

		if(p[i]==2)

		cnt++;

	}

	if(flag)

	cout<<mod_exp(cnt)<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.400297211619692x):
#include<cstdio>

#include<iostream>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<vector>

#include<string>

#include<queue>

#include<stack>

#include<set>

#include<map>

#include<sstream>

#include<bitset>

using namespace std;

#define pii pair<int,int>

#define pdd pair<double,double>

#define mp make_pair

#define pb push_back

#define ALL(x)	x.begin(),x.end()

#define fst first

#define sec second

#define PQ priority_queue

typedef long long ll;

const double eps = 1e-6;

const int maxn=1e6+10;;

const int inf=0x3f3f3f3f;

const ll mod=1e9+7;

const double pi=acos(-1.0);

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} 

ll quickmod(ll a,ll b,ll c)

{

  ll res=1;

  while (b)

  {

    if(b&1) res=res*a%c;

    a=a*a%c;

    b>>=1;

  }

  return res;

  

}

ll vis[maxn],vis2[maxn],tem;

int a[maxn];

int main() {

    int n,flag=0;

    cin>>n;

    for(int i=0;i<n;++i)

    {

       scanf("%lld",&a[i]);

       vis[a[i]]++;

       if(vis[0]>=2) {flag=1;break;}

       if(a[i]>0&&vis[a[i]]>=3) {flag=1;break;}

       if(vis[a[i]]==2&&vis2[a[i]]==0) {tem++;vis2[a[i]]=1;}

    }

    if(flag) cout<<0<<endl;

    else

    {

      ll ans=quickmod(2,tem,mod);

      cout<<ans<<endl;

    }

    

    return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

using namespace std;



long long con=1000000007,a[100070],cnt[100070],fac[100050];



long long fact(long long n)

{

    if(n==0)

    {

        return 1;

    }

    long long mul=1,i;



    mul=fac[n-1]*n;

    mul=mul%con;



    return mul;

}



int main()

{



    long long n,i,ans=1;



    for(i=0; i<100050; i++)

    {

        fac[i]=fact(i);

    }

    scanf("%lld",&n);



    for(i=0; i<n; i++)

    {

        scanf("%lld",&a[i]);

        cnt[a[i]]++;

    }



    for(i=1;i<100050; i++)

    {

        if(cnt[i]%2!=0)

        {

            printf("0");

            return 0;

        }





        ans*=fac[cnt[i]];

        ans=ans%con;

    }



    printf("%lld",ans);

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 3.3502990238856656x):
#include<cstdio>

#include<iostream>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<vector>

#include<string>

#include<queue>

#include<stack>

#include<set>

#include<map>

#include<sstream>

#include<bitset>

using namespace std;

#define pii pair<int,int>

#define pdd pair<double,double>

#define mp make_pair

#define pb push_back

#define ALL(x)	x.begin(),x.end()

#define fst first

#define sec second

#define PQ priority_queue

typedef long long ll;

const double eps = 1e-6;

const int maxn=1e6+10;;

const int inf=0x3f3f3f3f;

const ll mod=1e9+7;

const double pi=acos(-1.0);

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} 

ll quickmod(ll a,ll b,ll c)

{

  ll res=1;

  while (b)

  {

    if(b&1) res=res*a%c;

    a=a*a%c;

    b>>=1;

  }

  return res;

  

}

ll vis[maxn],vis2[maxn],tem;

int a[maxn];

int main() {

    int n,flag=0;

    cin>>n;

    for(int i=0;i<n;++i)

    {

       scanf("%lld",&a[i]);

       vis[a[i]]++;

       if(vis[0]>=2) {flag=1;break;}

       if(a[i]>0&&vis[a[i]]>=3) {flag=1;break;}

       if(vis[a[i]]==2&&vis2[a[i]]==0) {tem++;vis2[a[i]]=1;}

    }

    if(flag) cout<<0<<endl;

    else

    {

      ll ans=quickmod(2,tem,mod);

      cout<<ans<<endl;

    }

    

    return 0;

}