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

#include <cstdio>

#include <queue>

#include <vector>

#include <cstring>

#include <string>

#include <cmath>

#include <map>

#include <set>

#include <algorithm>

#define l(u) (u<<1)

#define r(u) (u<<1|1)

#define lson l, m, rt << 1

#define rson m + 1, r, rt << 1 | 1

#define root 1, n, 1

#define BUG puts("I am bug")

#define XY(x, y) printf("(%d %d)\n", x, y)

typedef long long ll;

using namespace std;



int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};

const int MAXN = 1010;





int main() {

    ios_base::sync_with_stdio(0);

    ll a, b;

    while (cin >> a >> b)

    {

        ll ans1 = __gcd(a, b);

        ll ans2 = a * b / ans1;

        cout << ans1 << ' ' << ans2 << '\n';

    }

    return 0;

}

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

#define LL long long

LL GCD(LL a,LL b)

{

    return b==0?a:GCD(b,a%b);

}

int main()

{

    LL a,b;

    while(scanf("%lld%lld",&a,&b)!=EOF)

    {

        LL c=GCD(a,b);

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

    }

    return 0;

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



using namespace std;



long long GCD(long long a,long long b)

{

    long long  gcd;

    if(b==0)

        gcd=a;

    else

        gcd=GCD(b,a%b);

    return gcd;

    

}

long long LCM(long long a,long long b)

{

    return a*b/GCD(a, b);

}





int main() {

    

    long long a,b;

    while(cin>>a>>b)

    {

        cout<<GCD(a,b)<<" "<<LCM(a, b)<<endl;

    }

    return 0;

}

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

#define LL long long

LL GCD(LL a,LL b)

{

    return b==0?a:GCD(b,a%b);

}

int main()

{

    LL a,b;

    while(scanf("%lld%lld",&a,&b)!=EOF)

    {

        LL c=GCD(a,b);

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

    }

    return 0;

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

#include<cstdio>

#include<algorithm>

#include<cctype>



using namespace std;



long long int gcd(long long int a, long long int b){

	if (a < b)

		swap(a, b);

	if (b == 0)

		return a;

	else 

	return gcd(b, a%b);

}



long long int lcm(long long int c, long long int d){

	return c*d / gcd(c, d);

}



int main(){

	long long int M, N;

	while (cin>>M>>N){

		cout << gcd(M, N) << " " << lcm(M, N) << "\n";

	}

	return 0;

}

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

#define LL long long

LL GCD(LL a,LL b)

{

    return b==0?a:GCD(b,a%b);

}

int main()

{

    LL a,b;

    while(scanf("%lld%lld",&a,&b)!=EOF)

    {

        LL c=GCD(a,b);

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

    }

    return 0;

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

#include <cstdio>

#include <algorithm>



using namespace std;



int main()

{

    long long int num1 , num2, gcd , res, lcm;

    while(scanf("%lld%lld",&num1,&num2)!=EOF){



        res = num1 * num2 ;

        while(num1 != num2){

            if(num1 > num2)

                num1 = num1 - num2 ;

            else

                num2 = num2 - num1 ;

        }

        gcd = num1 ;

        lcm = res / gcd ;

         printf("%lld %lld\n", gcd, lcm);

    }

    return 0;

}

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

#define LL long long

LL GCD(LL a,LL b)

{

    return b==0?a:GCD(b,a%b);

}

int main()

{

    LL a,b;

    while(scanf("%lld%lld",&a,&b)!=EOF)

    {

        LL c=GCD(a,b);

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

    }

    return 0;

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

#include <cstring>

#include <vector>

#include <set>

#include <map>

#include <string>

#include <cmath>

#include <cstdlib>

#include <algorithm>

#include <iostream>

#include <queue>

#include <stack>

#include <sstream>

using namespace std;



#define PQ priority_queue

#define P pair<int,int>

#define CLA(array) memset(array,0,sizeof array)

#define CLINF(array) memset(array,0x3f,sizeof array)

#define CLF(array) memset(array,-1,sizeof array)

#define DB(a) cout << "DEBUG " << a << endl;

typedef long long LL;

const int MAXN = 100000 + 50;

const int INF = 1 << 30;

LL gcd(LL a,LL b){

	if(a < b) swap(a,b);

	return b == 0 ? a : gcd(b,a % b);

}



int main(){

    //ios_base::sync_with_stdio(false);

	LL n,m;

	while(~scanf("%lld%lld",&n,&m)){

		LL ans = gcd(n,m);

		printf("%lld %lld\n",ans,n / ans * m);

	}





    return 0;

}

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

#define LL long long

LL GCD(LL a,LL b)

{

    return b==0?a:GCD(b,a%b);

}

int main()

{

    LL a,b;

    while(scanf("%lld%lld",&a,&b)!=EOF)

    {

        LL c=GCD(a,b);

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

    }

    return 0;

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

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <queue>

#include <vector>

#include <cmath>

#include <stack>

#include <map>

#include <set>

#define pi acos(-1)

#define LL long long

#define INF 0x3f3f3f3f

using namespace std;

typedef pair<int, int> P;

const int maxn = 1e5 + 5;



LL GCD(LL a, LL b)

{

    if (b == 0) return a;

    return GCD(b, a%b);

}

int main(void)

{

//	freopen("C:\\Users\\wave\\Desktop\\NULL.exe\\NULL\\in.txt","r", stdin);

    LL a, b;

    while (cin >> a >> b)

    {

        LL gcd = GCD(a, b);

        a /= gcd;

        b /= gcd;

        LL lcm = a * b * gcd;

        cout << gcd << " " << lcm << endl;

    }



    return 0;

}

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

#define LL long long

LL GCD(LL a,LL b)

{

    return b==0?a:GCD(b,a%b);

}

int main()

{

    LL a,b;

    while(scanf("%lld%lld",&a,&b)!=EOF)

    {

        LL c=GCD(a,b);

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

    }

    return 0;

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

#include <cstring>

#include <cstdlib>

#include <iostream>

#include <algorithm>



using namespace std;



typedef long long int ll;



ll GCD(ll x, ll y)

{

    return !y ? x : GCD(y, x % y);

}



ll LCM(ll x, ll y)

{

    return x * y / GCD(x, y);

}



int main()

{

    ll a, b;

    while (cin >> a >> b)

    {

        cout << GCD(a, b) << ' ' << LCM(a, b) << endl;

    }

    return 0;

}

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

#define LL long long

LL GCD(LL a,LL b)

{

    return b==0?a:GCD(b,a%b);

}

int main()

{

    LL a,b;

    while(scanf("%lld%lld",&a,&b)!=EOF)

    {

        LL c=GCD(a,b);

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

    }

    return 0;

}
// Slower C++ solution:
// #define _GLIBCXX_DEBUG

#include <bits/stdc++.h>



#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)

#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)

#define REP(i, n) FOR(i, 0, n)

#define REP1(i, n) FOR(i, 1, int(n) + 1)

#define RREP(i, n) RFOR(i, 0, n)

#define RREP1(i, n) RFOR(i, 1, int(n) + 1)

#define ALL(c) begin(c), end(c)



int _ = (

#ifndef LOCAL

    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),

#endif

    std::cout.precision(10), std::cout.setf(std::ios::fixed));



using ll = long long;

using ull = unsigned long long;

using ld = long double;

template <typename T> using vec = std::vector<T>;

using namespace std;



int main() {

  string S;

  cin >> S;



  const regex re("^A[a-z](?:[a-z]*C[a-z]*)[a-z]$");

  cout << (regex_match(S, re) ? "AC" : "WA") << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.108583239553775x):
// #define _GLIBCXX_DEBUG

#include <bits/stdc++.h>



#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)

#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)

#define REP(i, n) FOR(i, 0, n)

#define REP1(i, n) FOR(i, 1, int(n) + 1)

#define RREP(i, n) RFOR(i, 0, n)

#define RREP1(i, n) RFOR(i, 1, int(n) + 1)

#define ALL(c) begin(c), end(c)



int _ = (

#ifndef LOCAL

    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),

#endif

    std::cout.precision(10), std::cout.setf(std::ios::fixed));



using ll = long long;

using ull = unsigned long long;

using ld = long double;

template <typename T> using vec = std::vector<T>;

using namespace std;



int main() {

  string S;

  cin >> S;



  const regex re("^A[a-z]+C[a-z]+$");

  cout << (regex_match(S, re) ? "AC" : "WA") << endl;

  return 0;

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

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<iostream>

#include<vector>

#include<set>

#include<map>

#include<numeric>

#include<deque>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

const int INF=1e9+7;

const int MOD=998244353;

const int N = 1e6 + 5;

const ll inv2=499122177;

const double pi=acos(-1);

ll k[100005],s[100005];

ll qpmod(ll a,ll n)

{

	ll ret=1;

	while(n)

	{

	   	if(n&1)

	      	ret=(ret*a)%MOD;

	   	a=(a*a)%MOD;

		n>>=1;

	}

	return ret;

}

int main()

{

	ll n;

	int flag=1;

	scanf("%lld",&n);

	memset(k,0,sizeof(k));

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

	{

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

		if(s[i]==0&&i!=0)

			flag=0;

		if(s[0]!=0)

			flag=0;

		k[s[i]]++;

	}

	if(flag==0)

		printf("0\n");

	else

	{

		ll ans=1;

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

		{

			ans=(ans*qpmod(k[i],k[i+1]))%MOD;

		}

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

	}

    return 0;

}




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

using namespace std;



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);cout.tie(0);

	auto no=[&](){cout<<"0\n",exit(0);};

	int n;

	cin>>n;

	vector<int>d(n);

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

	int maxn=*max_element(d.begin(),d.end());

	if(maxn>n-1) no();

	vector<int>cnt(maxn+1);

	for(int i=0;i<n;i++) cnt[d[i]]++;

	if(cnt[0]!=1)no();

	if(d[0]!=0)no();

	int64_t ans=1;



	for(int i=1;i<cnt.size();i++){

		if(cnt[i]==0)no();

		for(int j=0;j<cnt[i];j++)

			ans= ans * cnt[i-1] % 998244353;

	}

	cout<<ans<<'\n';

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

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<iostream>

#include<vector>

#include<set>

#include<map>

#include<numeric>

#include<deque>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

const int INF=1e9+7;

const int MOD=998244353;

const int N = 1e6 + 5;

const ll inv2=499122177;

const double pi=acos(-1);

ll k[100005],s[100005];

ll qpmod(ll a,ll n)

{

	ll ret=1;

	while(n)

	{

	   	if(n&1)

	      	ret=(ret*a)%MOD;

	   	a=(a*a)%MOD;

		n>>=1;

	}

	return ret;

}

int main()

{

	ll n;

	int flag=1;

	scanf("%lld",&n);

	memset(k,0,sizeof(k));

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

	{

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

		if(s[i]==0&&i!=0)

			flag=0;

		if(s[0]!=0)

			flag=0;

		k[s[i]]++;

	}

	if(flag==0)

		printf("0\n");

	else

	{

		ll ans=1;

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

		{

			ans=(ans*qpmod(k[i],k[i+1]))%MOD;

		}

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

	}

    return 0;

}




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

#include<vector>

#include<string.h>

#include<queue>

typedef long long ll;

const ll m = 998244353;

ll v[1000000];

ll ksm(ll a, ll b) {

	ll c = 1;

	while (b) {

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

		a = a * a % m;

		b >>= 1;

	}

	return c;

}



using namespace std;

int main() {

	ll n,x,ma;

	cin >> n;

	ma = 0;

	cin >> x;

	v[x]++;

	if (x) {

		cout << "0\n";

		return 0;

	}



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

		cin >> x;

		v[x]++;

		if (ma < x) ma = x;

	}

	if (v[0] != 1) {

		cout << "0\n";

		return 0;

	}

		

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

		if (v[i] == 0) {

			cout << "0\n";

			return 0;

		}		

	}

	long long ans = 1;

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

		ans = (ans * ksm(v[i-1],v[i])) % m;

	}

	cout << ans << '\n';



	return 0;

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

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<iostream>

#include<vector>

#include<set>

#include<map>

#include<numeric>

#include<deque>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

const int INF=1e9+7;

const int MOD=998244353;

const int N = 1e6 + 5;

const ll inv2=499122177;

const double pi=acos(-1);

ll k[100005],s[100005];

ll qpmod(ll a,ll n)

{

	ll ret=1;

	while(n)

	{

	   	if(n&1)

	      	ret=(ret*a)%MOD;

	   	a=(a*a)%MOD;

		n>>=1;

	}

	return ret;

}

int main()

{

	ll n;

	int flag=1;

	scanf("%lld",&n);

	memset(k,0,sizeof(k));

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

	{

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

		if(s[i]==0&&i!=0)

			flag=0;

		if(s[0]!=0)

			flag=0;

		k[s[i]]++;

	}

	if(flag==0)

		printf("0\n");

	else

	{

		ll ans=1;

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

		{

			ans=(ans*qpmod(k[i],k[i+1]))%MOD;

		}

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

	}

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 1.7976903631522485x):
#pragma GCC optimize(2) 

#include<iostream>



using namespace std;

const int mod=998244353;

long long a[100010];

long long n,x;

long long ksm(long long a,long long b){

	long long res=1;

	while(b){

		if(b&1){

			res*=a;

			res%=mod;

		}

		a*=a;

		a%=mod;

		b>>=1;

	}

	return res;

}



int main(){

//	ios::sync_with_stdio(0);

//	cin.tie(0),cout.tie(0);

	scanf("%lld",&n);

	int flag=0;

	scanf("%lld",&x);

	int ans=x;

	if(x!=0) flag=1;

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

		scanf("%lld",&x);

		a[x]++;

		if(x==0) flag=1;

		if(x>ans){

			ans=x;

		}

	}

	

	if(flag){

		printf("0\n");

	}

	else{

	long long sum=1;

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

			if(a[i]==0){

				flag=1;

				break;

			}

			sum*=ksm(a[i],a[i+1]);

			sum%=mod;

//			cout<<"SUM:"<<sum<<endl;

		}

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

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

	}

	return 0;

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

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<iostream>

#include<vector>

#include<set>

#include<map>

#include<numeric>

#include<deque>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

const int INF=1e9+7;

const int MOD=998244353;

const int N = 1e6 + 5;

const ll inv2=499122177;

const double pi=acos(-1);

ll k[100005],s[100005];

ll qpmod(ll a,ll n)

{

	ll ret=1;

	while(n)

	{

	   	if(n&1)

	      	ret=(ret*a)%MOD;

	   	a=(a*a)%MOD;

		n>>=1;

	}

	return ret;

}

int main()

{

	ll n;

	int flag=1;

	scanf("%lld",&n);

	memset(k,0,sizeof(k));

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

	{

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

		if(s[i]==0&&i!=0)

			flag=0;

		if(s[0]!=0)

			flag=0;

		k[s[i]]++;

	}

	if(flag==0)

		printf("0\n");

	else

	{

		ll ans=1;

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

		{

			ans=(ans*qpmod(k[i],k[i+1]))%MOD;

		}

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

	}

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 1.7976903631522485x):
#pragma GCC optimize(2) 

#include<iostream>

 

using namespace std;

const int mod=998244353;

long long a[100010];

long long n,x;

long long ksm(long long a,long long b){

	long long res=1;

	while(b){

		if(b&1){

			res*=a;

			res%=mod;

		}

		a*=a;

		a%=mod;

		b>>=1;

	}

	return res;

}

 

int main(){

//	ios::sync_with_stdio(0);

//	cin.tie(0),cout.tie(0);

	scanf("%lld",&n);

	int flag=0;

	scanf("%lld",&x);

	int ans=x;

	if(x!=0) flag=1;

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

		scanf("%lld",&x);

		a[x]++;

		if(x==0) flag=1;

		if(x>ans){

			ans=x;

		}

	}

	

	if(flag){

		printf("0\n");

	}

	else{

	long long sum=1;

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

			if(a[i]==0){

				flag=1;

				break;

			}

			sum*=ksm(a[i],a[i+1]);

			sum%=mod;

//			cout<<"SUM:"<<sum<<endl;

		}

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

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

	}

	return 0;

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

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<iostream>

#include<vector>

#include<set>

#include<map>

#include<numeric>

#include<deque>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

const int INF=1e9+7;

const int MOD=998244353;

const int N = 1e6 + 5;

const ll inv2=499122177;

const double pi=acos(-1);

ll k[100005],s[100005];

ll qpmod(ll a,ll n)

{

	ll ret=1;

	while(n)

	{

	   	if(n&1)

	      	ret=(ret*a)%MOD;

	   	a=(a*a)%MOD;

		n>>=1;

	}

	return ret;

}

int main()

{

	ll n;

	int flag=1;

	scanf("%lld",&n);

	memset(k,0,sizeof(k));

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

	{

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

		if(s[i]==0&&i!=0)

			flag=0;

		if(s[0]!=0)

			flag=0;

		k[s[i]]++;

	}

	if(flag==0)

		printf("0\n");

	else

	{

		ll ans=1;

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

		{

			ans=(ans*qpmod(k[i],k[i+1]))%MOD;

		}

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

	}

    return 0;

}




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

#include<algorithm>

using namespace std;

typedef long long ll;

const int maxn=1e5+10;

const ll mod=998244353;

ll a[maxn];

ll poow(ll a,ll b)

{

	ll ans=1;

	while(b)

	{

		if(b&1) ans=(ans*a)%mod;

		a=(a*a)%mod;

		b>>=1;

	}

	return ans%mod;

}

int main()

{

	ll x,n;

	cin>>n;

	ll ma=0;

	bool flag=0;

	cin>>x;

	if(x!=0) flag=1;

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

	{

		cin>>x;

		a[x]++;	

		if(!x) flag=1;

		ma=max(ma,x);

	}

	ll sum=1;

	if(flag) cout<<0<<"\n";

	else{

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

		{

			sum=(sum*poow(a[i-1],a[i]))%mod;

		}

		cout<<sum<<"\n";

	}

	return 0;

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

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<iostream>

#include<vector>

#include<set>

#include<map>

#include<numeric>

#include<deque>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

const int INF=1e9+7;

const int MOD=998244353;

const int N = 1e6 + 5;

const ll inv2=499122177;

const double pi=acos(-1);

ll k[100005],s[100005];

ll qpmod(ll a,ll n)

{

	ll ret=1;

	while(n)

	{

	   	if(n&1)

	      	ret=(ret*a)%MOD;

	   	a=(a*a)%MOD;

		n>>=1;

	}

	return ret;

}

int main()

{

	ll n;

	int flag=1;

	scanf("%lld",&n);

	memset(k,0,sizeof(k));

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

	{

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

		if(s[i]==0&&i!=0)

			flag=0;

		if(s[0]!=0)

			flag=0;

		k[s[i]]++;

	}

	if(flag==0)

		printf("0\n");

	else

	{

		ll ans=1;

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

		{

			ans=(ans*qpmod(k[i],k[i+1]))%MOD;

		}

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

	}

    return 0;

}




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

#include <algorithm>

#include <string>

#include <cstring>

#include <map>

#include <set>

#include <deque>

#include <queue>

#include <vector>

#include <cstdio>

#include <cstdlib>

#include <bits/stdc++.h>

#define PI acos(-1)

#define fs first

#define sc second

#define debug freopen("1.in","r",stdin),freopen("1.out","w",stdout);

#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll maxn = 1e6 + 10;

const ll mod = 998244353;



int n, arr[maxn];

ll ans = 1;

ll mul(ll x,ll y,ll z)

{

    ll sm = x / z * y;

    return ( x * y - sm * z + z ) % z;

}

ll qpow(ll m, ll k, ll p){

    ll res = 1 % p;

    while (k){

        if (k&1) res = res * m % p;

        m = m * m % p;

        k >>= 1;

    }

    return res;

}



int main(){

    ios;

    cin >> n;

    cin >> arr[1];

    if (arr[1] != 0){

        cout << 0;

        return 0;

    }

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

        cin >> arr[i];

        if (arr[i] == 0){

            cout << 0;

            return 0;

        }

    }

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

    ll tmp = 1, tmpp = 1;

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

        if (arr[i] - arr[i - 1] != 1 && arr[i] - arr[i - 1] != 0){

            cout << 0;

            return 0;

        }

        if (arr[i] == arr[i + 1])

            tmpp ++;

        else{

            ans = mul(ans, qpow(tmp, tmpp, mod), mod);

            tmp = tmpp;

            tmpp = 1;

        }

    }

    cout << ans;



    return 0;

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

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<iostream>

#include<vector>

#include<set>

#include<map>

#include<numeric>

#include<deque>

using namespace std;

typedef long long ll;

typedef pair<int,int> PII;

const int INF=1e9+7;

const int MOD=998244353;

const int N = 1e6 + 5;

const ll inv2=499122177;

const double pi=acos(-1);

ll k[100005],s[100005];

ll qpmod(ll a,ll n)

{

	ll ret=1;

	while(n)

	{

	   	if(n&1)

	      	ret=(ret*a)%MOD;

	   	a=(a*a)%MOD;

		n>>=1;

	}

	return ret;

}

int main()

{

	ll n;

	int flag=1;

	scanf("%lld",&n);

	memset(k,0,sizeof(k));

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

	{

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

		if(s[i]==0&&i!=0)

			flag=0;

		if(s[0]!=0)

			flag=0;

		k[s[i]]++;

	}

	if(flag==0)

		printf("0\n");

	else

	{

		ll ans=1;

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

		{

			ans=(ans*qpmod(k[i],k[i+1]))%MOD;

		}

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

	}

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 1.7842338794714705x):
#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/stack:16777216")

#include <string>

#include <vector>

#include <map>

#include <list>

#include <iterator>

#include <set>

#include <queue>

#include <iostream>

#include <sstream>

#include <stack>

#include <deque>

#include <cmath>  

#include <memory.h>

#include <cstdlib>

#include <cstdio>

#include <cctype>

#include <algorithm>

#include <utility>

#include <time.h>

#include <bitset>

using namespace std;



#define FOR(i, a, b) for(int i = (a); i < (b); ++i)

#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)

#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(A,value) memset(A,value,sizeof(A))



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

#define SZ(V) (int)V.size()

#define PB push_back

#define MP make_pair

const double PI=acos(-1.0);



typedef long long Int;

typedef long long LL;

typedef unsigned long long UINT;

typedef vector <int> VI;

typedef pair <int, int> PII;

typedef pair <double, double> PDD;



const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL) INF;



const int MAX = 200007;

const int MAX2 = 1000007;

const int LEN = 21;

const int BASE = 1000000000;



const int MOD = 998244353;



int n;

int C[MAX];



int main()

{

  cin >> n;

  FOR (i,0,n)

  {

    int x;

    scanf("%d", &x);

    C[x] ++;



    if (i == 0 && x != 0)

    {

      cout << 0 << endl;

      return 0;

    }

  }



  int tot = 1;



  if (C[0] != 1)

  {

    cout << 0 << endl;

    return 0;

  }

  

  Int res = 1;



  FOR (i,1,n)

    FOR (j,0,C[i])

      res = res * C[i-1] % MOD;





  cout << res << endl;



  













 

  return 0;

}