stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long n,mx=0;

    cin >> n;

    long long i,arr[10000];

    for(i=sqrt(n)+1;i>0;i--)

    {

        if(n%i==0)

        {

            mx=i;

            break;

        }

    }

    cout << mx-1 + n/mx-1 << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
/*

Md.Shahnewaz Siddique Labib

Dept. of CSE

IUT,19

*/

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);

#define vi vector<int>

#define pii pair<int, int>

#define vpii vector<pair<int, int>>

#define ll long long

#define ld long double

#define pb push_back

#define mp make_pair



using namespace std;



int main(){

    fastio;

    ll n, moves;

    cin >> n;

    moves = n;

    for(long long i = 1; i*i < n + 1; i++) if(n%i == 0) moves = min(moves, i + n/i - 2);

    cout << moves;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



int main() {

    uint64_t n;

    cin >> n;



    uint64_t minima = UINT64_MAX;

    for (uint64_t x = 1; x*x <= n; x++) {

        if (n % x == 0) {

            uint64_t y = n / x;

            minima = min(minima, (x + y - 2));

        }

    }



    cout << minima << endl;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



int main()

{

    long long n  , sum=1e18;

    cin>>n;

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

    {

        if( n%i==0 )

        {

            sum=min( sum , ( ( i-1 )+ ( (n/i) -1 ) ) );

        }

    }

    cout<<sum<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cmath>

#include<math.h> 

#include<cstring>

#include<iostream>

#include<algorithm>

#define pi acos(-1);

#define MAX 1e5;

using namespace std;

typedef long long ll;

int main()

{

	ll N;

	float a;

	ll b;

	cin >> N;

	int n = sqrt(N)+1;

	ll ans=0;

	//cout << n;

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

		a = N / (i*1.0);

		b = N / i;

		if (N % i==0) {

			if (ans == 0)ans = (i + b - 2);

			else ans = (ans > (i + b - 2)) ? (i + b - 2) : ans;

		}

	}

	cout << ans;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main(){

    long long int n,i,j,d=1,ans;

    cin>>n;

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

        if(n%i==0){d=i;}

    }

    ans=d+n/d-2;

    cout<<ans<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define ms(x,y) memset(x, y, sizeof(x))

#define lowbit(x) ((x)&(-x))

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

typedef long long LL;

typedef pair<int,int> pii;

typedef pair<LL,LL> pll;





void run_case() {

    LL n; cin >> n;

    LL x = n+1, y = n+1;

    for(LL i = 1; i*i <= n; ++i) {

        if(n % i == 0) {

            LL nx = i, ny = n / i;

            if(nx + ny < x + y) x = nx, y = ny;

        }

    }

    cout << (x+y-2);

}





int main() {

    ios::sync_with_stdio(false), cin.tie(0);

    cout.flags(ios::fixed);cout.precision(9);

    //int t; cin >> t;

    //while(t--)

    run_case();

    cout.flush();

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long int

using namespace std;

//ll s[500500];

//const int N=1e7+5;

//ll f[N],n,ans;

int main(){

   ll n;

  cin >> n;

  ll ans = n - 1;

  for (ll i = 1; i * i <= n; i++) {

    if (n%i)continue;

    ll j = n / i;

    ans = min(ans, i + j - 2);

  }

  cout << ans << "\n";

}






// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;



int main() {

    long long int n,sum;



    cin>>n;

    sum=n-1;

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

        if(n%i==0){

            long long int minsum=i+n/i-2;

            if(sum>minsum)

                sum=minsum;

        }

    }

    cout<<sum;







    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

typedef long long ll;

int main()

{

    ll n;

    cin >> n;

    ll ans=0;

    for(ll i=1;i*i<=n;i++)

    {

        if(n%i==0)

        {

            ans = i;

        }

    }

    cout << (ans-1)+(n/ans-1);

    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cmath>

#define ll long long

using namespace std;

int main(){

    ll n,k;

    scanf("%lld",&n);

    k=ceil(sqrt(n));

    while(k){

        if(n%k==0){

            printf("%lld",k-1+n/k-1);

            return 0;

        }

        k--;

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



const int N = 200010;

typedef long long ll;



ll dp[N][5];

int a[N];



void update(ll &a, ll b){

    if (a == -1 || a > b){

        a = b;

    }

}



int main(){

    int n;

    scanf("%d", &n);

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

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

    }

    memset(dp, -1, sizeof(dp));

    dp[0][0] = 0;

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

        for (int j = 0; j <= 0; ++ j){

            if (dp[i - 1][j] != -1){

                update(dp[i][0], dp[i - 1][j] + a[i]);

            }

        }

        for (int j = 0; j <= 1; ++ j){

            if (dp[i - 1][j] != -1){

                update(dp[i][1], dp[i - 1][j] + (a[i] == 0 ? 2 : a[i] & 1));

            }

        }

        for (int j = 0; j <= 2; ++ j){

            if (dp[i - 1][j] != -1){

                update(dp[i][2], dp[i - 1][j] + !(a[i] & 1));

            }

        }

        for (int j = 0; j <= 3; ++ j){

            if (dp[i - 1][j] != -1){

                update(dp[i][3], dp[i - 1][j] + (a[i] == 0 ? 2 : a[i] & 1));

            }

        }

        for (int j = 0; j <= 4; ++ j){

            if (dp[i - 1][j] != -1){

                update(dp[i][4], dp[i - 1][j] + a[i]);

            }

        }

    }

    printf("%lld\n", dp[n + 1][4]);

    return 0;

} 

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define inf 0x3f3f3f3f

typedef long long ll;

const int N=2e5+5;

int n,a[N][3];

ll dp[N][5];

int main()

{

    scanf("%d",&n);

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

    {

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

        a[i][1]=a[i][0]%2==0;

        a[i][2]=a[i][0]==0?2:a[i][0]%2;

    }

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

    {

        ll mn=1e18;

        for(int j=0;j<5;j++)

        {

            mn=min(mn,dp[i-1][j]);

            ll s;

            if(j==0) s=a[i][0];

            else if(j==1) s=a[i][2];

            else if(j==2) s=a[i][1];

            else if(j==3) s=a[i][2];

            else s=a[i][0];

            dp[i][j]=mn+s;

        }

    }

    ll ans=1e18;

    for(int i=0;i<5;i++) ans=min(ans,dp[n][i]);

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

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <map>

#include <set>

#include <queue>

#include <stack>

#include <cmath>

#include <cstdio>

#include <string>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;



#define ls st<<1

#define rs st<<1|1

#define LL long long

#define CLR(a,b) memset(a,(b),sizeof(a))



const int MAXN = 1e5+11;

const int mod = 1e9+7;

const int INF = 0x3f3f3f3f;



/* ------------------------基本函数-------------------------*/





LL pow_mod(LL a, LL b) {

	LL ans = 1;

	while(b) {

		if(b&1)

			ans = (ans*a) % mod;

		a = (a*a) % mod;

		b /= 2;

	}

	return ans;

}



int arr[MAXN];

int main() {

	int n;

	cin >> n;

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

		cin >>arr[i];

	}

	bool flag = true;

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

	if(n&1) {

		if(arr[1]!=0) flag = false;

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

			//cout<<arr[i]<<' '<<j<< endl;

			if(arr[i] != j) {

				flag = false; break;

			}

		}

	}

	else {

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

			if(arr[i] != j) {

				flag = false; break;

			}

		}

	}

	if(flag) {

		LL xx = (LL)(n/2);

		//cout << xx<< endl;

		cout << pow_mod(2,xx) << endl;

	}

	else cout << 0 << endl;



return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

int vist[100005];

int Q(int n){

	long long x = 2,ans = 1;

	while(n>0){

		if(n&1)		ans = ans*x%1000000007;

		x = x*x%1000000007;

		n/=2;

	}

	return ans;

}

void Init(int n){

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

		vist[i]	= 0;

}

int main()

{

	int n,m,F;

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

		Init(n);

		F = true;

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

			scanf("%d",&m);

			vist[m]++;		if(m>n-1)	F = false;

		}

		if(n%2!=0){

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

				if(i==0&&vist[i]!=1)		F = false;	

				if(i!=0&&i%2==0&&vist[i]!=2)		F = false;

				if(i%2!=0&&vist[i]!=0)		F = false;	

			}

			if(F){

				int c = Q((n-1)/2);

				printf("%d\n",c%1000000007);

			}

			else	printf("0\n");

		}

		

		else{

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

				if(i%2!=0&&vist[i]!=2)		F = false;

				if(i%2==0&&vist[i]!=0)		F = false;

			}

			if(F){

				int c = Q(n/2);

				printf("%d\n",c%1000000007);

			}

			else	printf("0\n");

		}

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

long long powmod(long long y,long long x){

	long long ans=1;

	while(x){

		if(x&1)

			ans=(y*ans)%1000000007;

		x/=2;

		y=(y*y)%1000000007;

		

	}

	return ans;

}

int main(){

	int n;

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

		int flag=0; 

		int a[100005];

	

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

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

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

		}

		sort(a,a+n);

		if(n%2){

			if(a[0]!=0||a[1]==0){

				flag=1;

			}

		}

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

			if(flag==1) break;

			if((n-1-a[i])%2) {

				flag=1;

				break;

			}

			if((a[i]==a[i+1]||a[i]==a[i-1])&&a[i+1]!=a[i-1])

				continue;

			else {

				flag=1;	

				break;

				}

		}

		if(n==1)

			printf("1\n");		

		else if(flag)printf("0\n");

		else printf("%lld\n",powmod((long long)2,(long long)n/2));

		

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

int vist[100005];

int Q(int n){

	long long x = 2,ans = 1;

	while(n>0){

		if(n&1)		ans = ans*x%1000000007;

		x = x*x%1000000007;

		n/=2;

	}

	return ans;

}

void Init(int n){

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

		vist[i]	= 0;

}

int main()

{

	int n,m,F;

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

		Init(n);

		F = true;

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

			scanf("%d",&m);

			vist[m]++;		if(m>n-1)	F = false;

		}

		if(n%2!=0){

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

				if(i==0&&vist[i]!=1)		F = false;	

				if(i!=0&&i%2==0&&vist[i]!=2)		F = false;

				if(i%2!=0&&vist[i]!=0)		F = false;	

			}

			if(F){

				int c = Q((n-1)/2);

				printf("%d\n",c%1000000007);

			}

			else	printf("0\n");

		}

		

		else{

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

				if(i%2!=0&&vist[i]!=2)		F = false;

				if(i%2==0&&vist[i]!=0)		F = false;

			}

			if(F){

				int c = Q(n/2);

				printf("%d\n",c%1000000007);

			}

			else	printf("0\n");

		}

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

using namespace std;

const long long M=1e9+7;

int main()

{

	int n;

	while(cin>>n)

	{

		int flag=1;

		int a[100005],b[100005];

		memset(b,0,sizeof(b));

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

		{

			cin>>a[i];

		}

		if(n%2==1)

		{	

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

			{

				b[a[i]]++;

			}

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

			{

				if(b[0]!=1)

				{

				    flag=0;

				    break;

			    }

				else if(b[i]==2)

				continue;

				else

				{

					flag=0;

					break;

				}

			} 

		}

		if(n%2==0)

		{

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

			{

				b[a[i]]++;

			}

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

			{

				if(b[i]==2)

				continue;

				else

				{

					flag=0;

					break;

				}

			}

	    }

	    long long sum=1;

		if(flag==1)

		{

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

			{

				sum*=2;

				sum%=M;

			}

			cout<<sum<<endl;

		}

		else

		cout<<"0"<<endl;

	}

	return 0;

} 

// Optimized solution to the same problem (faster):
#include<iostream>

#include<algorithm>

#include<map>

using namespace std;

typedef long long ll;

long long mod=1e9+7;



int main()

{

	int n;

	cin>>n;

	int a[n];

	map<ll,ll>m;

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

		{

			cin>>a[i];

			m[a[i]]++;

		}

	

	  if(m.count(0))

	  {

    	if(n%2==0 || m[0] != 1){

     		 cout << 0 << endl;

      	return 0;

      	}

    	m.erase(0);

  	  }

  

  	  ll ans = 1;

  	for(auto ite:m){

    if(ite.second %2 != 0){

      cout << 0 << endl;

      return 0;

    }

    ans *= ite.second % mod;

    ans %= mod;

  }

  cout << ans%mod << endl;

  

  

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<string>

using namespace std;



typedef long long ll;



const ll mod = 1e9 + 7;

const int maxn = 1e5 + 5;



int a[maxn];



ll fast_mod(ll base, ll n) {

	ll res = 1;

	while (n > 0) {

		if (n & 1) res = res * base % mod;

		base = base * base % mod;

		n >>= 1;

	}

	return res;

}



int main() {

	int n, num;

	cin >> n;

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

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

		cin >> num;

		a[num]++;

		if (a[num] > 2 || a[0] > 1 || (n - 1 + num) % 2) {

			printf("0\n"); return 0;

		}

	}

	cout << fast_mod(2, n / 2) << endl;

}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<algorithm>

#include<map>

using namespace std;

typedef long long ll;

long long mod=1e9+7;



int main()

{

	int n;

	cin>>n;

	int a[n];

	map<ll,ll>m;

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

		{

			cin>>a[i];

			m[a[i]]++;

		}

	

	  if(m.count(0))

	  {

    	if(n%2==0 || m[0] != 1){

     		 cout << 0 << endl;

      	return 0;

      	}

    	m.erase(0);

  	  }

  

  	  ll ans = 1;

  	for(auto ite:m){

    if(ite.second %2 != 0){

      cout << 0 << endl;

      return 0;

    }

    ans *= ite.second % mod;

    ans %= mod;

  }

  cout << ans%mod << endl;

  

  

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

typedef long long ll;



ll mod_pow(ll x,ll n,ll mod){

	ll res=1;

	while(n>0){

		if(n&1) res=res*x%mod;

		x=x*x%mod;

		n>>=1;

	}

	return res;

}

int a[100005];

int main()

{

	int n;

	ll mod=1000000000+7;

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

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

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

		sort(a,a+n);

		int flag=1;

		if(n%2==1){

			if(n==1){

				if(a[0]==0){

					

				}else{

					flag=0;

				}

			}

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

				if(i%2==1){

					if(a[i]==a[i-1]+2){

						

					}else{

						flag=0;

					}

				}else{

					if(a[i]==a[i-2]+2){

						

					}else{

						flag=0;

					}

				}

			}

		}else{

			if(a[0]!=a[1]) flag=0;

			if(a[0]!=1) flag=0;

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

				if(i%2==0){

					if(a[i]==a[i-1]+2){

						

					}else{

						flag=0;

					}

				}else{

					if(a[i]==a[i-2]+2){

						

					}else{

						flag=0;

					}

				}

			}

			

		}

		ll l=n/2;

		if(flag==0){

			printf("0\n");

		}else{

			printf("%lld\n",mod_pow(2,l,mod));

			

			

			

		}

	}

	

	return 0;

}

// Optimized solution to the same problem (faster):
//快速幂,2^n

#include<cstdio>

#define MOD 1000000007

long long fast(int a,int b)

{

	long long ans=1,x=a;

	while(b)

	{	

		if(b&1)     //奇数 

		{

			ans=(ans*x)%MOD;

		}

		x=(x*x)%MOD;

		b=b/2;

	}

	return ans;

 }	

int vis[100000+5];

int main()

{

	long long n,flag=0;

	scanf("%lld",&n);

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

	{

		int x;

		scanf("%d",&x);

		vis[x]++;

	}

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

	{

		if(vis[i]==0||vis[i]==2)

		{

			continue;

		}

		else

		{

			flag=1;

		}

	}

	if(n%2==0&&vis[0]!=0)

	{

		flag=1;

	}

	if(n%2==1&&vis[0]!=1)

	{

		flag=1;

	}

	if(flag)

	printf("0\n");

	else

	{

		n=n/2;

		long long ans=fast(2,n);

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

	 } 

	return 0;

//	long long a,b;

//	scanf("%lld%lld",&a,&b);

//	printf("%lld\n",fast(a,b));

 } 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;	

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: