stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
/*------------------------------------------------------------------------------------------------|

| %%%%%%%%%%%%%%%%%%%%%%%%%MD.ASANURJAMAL ANOWAR HOSSAIN ANU%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |

| %%%%%%%%%%%%%%%%%%%%%%%%%COMPUTER SCIENCE AND ENGINEERING%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |

| %%%%%%%%%%%%%%%%%%%%%%%%%ISLAMIC UNIVERSITY KUSHTIA%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |

| %%%%%%%%%%%%%%%%%%%%%%%%%BANGLADESH%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |

|-------------------------------------------------------------------------------------------------*/

#include <algorithm>

#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <string>

#include <cmath>

#include <list>

#include <map>

#include <fstream>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <bitset>

#include <cctype>

#include <vector>

#include <complex>

#include <ctime>

#include <deque>

#include <memory>

#include <utility>



#define S(a) scanf("%d",&a)

#define SL(a) scanf("%ld",&a)

#define S2(a,b) scanf("%d%d",&a,&b)

#define SL2(a,b) scanf("%ld%ld",&a,&b)

#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)

#define SL3(a,b,c) scanf("%ld%ld%ld",&a,&b,&c)

#define SLL(a) scanf("%lld",&a)

#define SLL2(a,b) scanf("%lld%lld",&a,&b)

#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

#define SS(a) scanf("%s",a)

#define SC(a) scanf("%c",&a)

#define SD(a) scanf("%lf",&a)

#define P(a) printf("%d",a)

#define PL(a) printf("%ld",a)

#define PLL(a) printf("%lld",a)

#define PD(a) printf("%lf",a)

#define PC(a) printf("%c",a)

#define PS(a) printf("%s",a)

#define CS(kk) printf("Case %ld: ",kk++)

#define NL(kk) printf("\n")

#define PI 3.14159265358979323846264338327950

#define eps 1e-9

#define MAX(a,b) (a>b?a:b)

#define MIN(a,b) (a<b?a:b)



using namespace std;



long long gcd(long long  a,long long b)

{

while(b>0)

{

a=a%b;

a=a^b;

b=b^a;

a=a^b;

}

return a;

}



long long lcm(long a,long long b)

{

    long long x=(a*b)/gcd(a,b);

    return x;

}

int main()

{

    long long i,ii,l,p,s,n,ll;

    long long a,b,c;

    //cin>>n;

    while(cin>>a>>b)

    {

     l=gcd(a,b);

     ll=lcm(a,b);

     cout<<l<<" "<<ll<<endl;

    }

 return 0;

}

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

}

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

#include<iostream>

using namespace std;

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

{

    if(a==0&&b==0)

        return 0;

    if(a==0) return 1;

    if(b==0) return a;

    else return GCD(b,a%b);

}

int main()

{

    long long x,y;

    while(cin>>x>>y)

    {

        long long ans1=GCD(x,y);

        long long ans2=(x*y)/ans1;

        cout<<ans1<<" "<<ans2<<"\n";

    }

	return 0;

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}

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

}


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

}


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

}




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

} 

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

#include<string.h>

#include<iostream>

#include<algorithm>

#include<string.h>

#include<math.h>

#define ll long long

using namespace std;

const  ll mod=998244353;

ll qp(ll a,ll k)

{

	ll ans=1;

	a%=mod;

	while(k)

	{

		if(k%2)

			ans=(ans*a)%mod;

		a=(a*a)%mod;

		k/=2;

	}

	return ans;

}

int main()

{

    int n;

    scanf("%d",&n);

    int a[100005],i;

    int b[100005],flag=1;

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

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

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

    if(a[0]!=0)

        printf("0\n");

    else

    {

        ll ans=1;

        int t;

        for(i=n-1;b[i]==0;i--);

        t=i;

        if(b[0]==1)

        {

            for(i=2; i<=t; i++)

            {

                if(b[i]==0)

                {

                    flag=0;

                    break;

                }

                ans=(ans*(ll)qp(b[i-1],b[i]))%mod;

            }

            if(flag==1)

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

            else

            	printf("0\n");

        }

        else

            printf("0\n");

    }



    return 0;

}


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

#include<string.h>

#include<iostream>

#include<algorithm>

#include<string.h>

#include<math.h>

#define ll long long

using namespace std;

ll b[1000005];

int main()

{

    int n;

    scanf("%d",&n);

    

    ll a[100005],i;

    

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

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

    if(n>=1e5)

        a[-2]=0;

    if(a[0]!=0)

            printf("0\n");

    else

    {

        ll ans=1;

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

            b[a[i]]++;

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

        {

            ans*=b[a[i]-1];

            ans%=998244353;

        }



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

    }

    return 0;

}


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

#include<string.h>

#include<iostream>

#include<algorithm>

#include<string.h>

#include<math.h>

#define ll long long

using namespace std;

ll b[1000005];

int main()

{

    int n;

    scanf("%d",&n);

    

    ll a[100005],i;

    

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

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

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

    if(n>=1e5)

        a[-2]=0;

    if(a[0]!=0)

            printf("0\n");

    else

    {

        ll ans=1;

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

            b[a[i]]++;

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

        {

            ans*=b[a[i]-1];

            ans%=998244353;

        }



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

    }

    return 0;

}


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

#include<string.h>

#include<iostream>

#include<algorithm>

#include<string.h>

#include<math.h>

#define ll long long

using namespace std;

ll b[100005];

int main()

{

    int n;

    scanf("%d",&n);

    

    ll a[100005],i;

    

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

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

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

    if(n>=1e5)

        a[-2]=0;

    if(a[0]!=0)

            printf("0\n");

    else

    {

        ll ans=1;

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

            b[a[i]]++;

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

        {

            ans*=b[a[i]-1];

            ans%=998244353;

        }



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

    }

    return 0;

}


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

using namespace std;

typedef long long ll;

const int mod= 998244353;

int D[100005];

int num[100005];

ll multi(ll a,ll b,ll mod){

	ll ans=0;

	while(b){

		if(b&1)

			ans=(ans+a)%mod;

		a=(a<<1)%mod;

		b>>=1;

	}

	return ans;

}

ll qpow(ll a,ll b,ll mod){

	ll ans=1;

	while(b){

		if(b&1)

			ans=multi(ans,a,mod);

		a=multi(a,a,mod);

		b>>=1;

	}

	return ans;

}

int main(){

	int n;

	scanf("%d",&n);

	int m=0;

	memset(num,0,sizeof num);

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

		scanf("%d",D+i);

		m=max(m,D[i]);

		num[D[i]]++;

	}

	if(num[0]!=1||D[0]!=0){

		printf("0");

		return 0;

	}

	ll ans=1;

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

		if(num[i]==0){

			ans=0;

			break;

		}

		ans=ans*qpow(num[i-1],num[i],mod)%mod;

	}

	printf("%lld",(ans+mod)%mod);

}

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

using namespace std;

typedef long long ll;

const int N=1E5+7;

ll arr[N];

const int MOD=998244353;

ll ksm(ll x, ll y){

	ll res=1;

	while(y){

		if(y&1) res=res*x%MOD;

		x=x*x%MOD;

		y>>=1;

	}

	return res%MOD;

}



int main(){

	ll n;

	cin>>n;

	ll sum=1;

	ll x;

	ll s=0;

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

		cin>>x;

		if(i==1&&x!=0) sum=0;

		arr[x]++;

		s=max(s,x);

	}

	for(int i=s;i>=0;i--){

		if(arr[i]==0) sum=0;

		if(i>1)	sum=sum*ksm(arr[i-1],arr[i])%MOD;

	}

	if(arr[0]>1) sum=0;

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

	

	return 0;

}

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

using namespace std;

typedef long long ll;

const int MAXN = 1e5 + 10;



ll d[MAXN], s[MAXN];



ll quick_pow(ll a, ll b, ll mod) {

	ll ans = 1;

	while(b) {

		if(b & 1) {

			ans = ans * a % mod;

		}

		a = a * a % mod;

		b >>= 1;

	}

	return ans;

}



int main() {

	ios::sync_with_stdio(false);

	ll n, num, mod = 998244353;

	while(cin >> n) {

		ll maxd = -1;

		memset(d, 0, sizeof(d));

		memset(s, 0, sizeof(s));

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

			cin >> num;

			s[i] = num;

			d[num]++;

			maxd = max(maxd, num);

		}

		ll ans;

		if(s[0] != 0 || d[0] != 1) {

			ans = 0;

		} else if(n == 1) {

			if(d[0] == 1 && s[0] == 0) {

				ans = 1;

			} else {

				ans = 0;

			}

		} else {

			ans = 1;

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

				ans = ans * quick_pow(d[i], d[i + 1], mod) % mod;

			}

		}

		cout << ans << endl;

	}

	return 0;

}

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

using namespace std;

typedef long long ll;

const int N=1E5+7;

ll arr[N];

const int MOD=998244353;

ll ksm(ll x, ll y){

	ll res=1;

	while(y){

		if(y&1) res=res*x%MOD;

		x=x*x%MOD;

		y>>=1;

	}

	return res%MOD;

}



int main(){

	ll n;

	cin>>n;

	ll sum=1;

	ll x;

	ll s=0;

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

		cin>>x;

		if(i==1&&x!=0) sum=0;

		arr[x]++;

		s=max(s,x);

	}

	for(int i=s;i>=0;i--){

		if(arr[i]==0) sum=0;

		if(i>1)	sum=sum*ksm(arr[i-1],arr[i])%MOD;

	}

	if(arr[0]>1) sum=0;

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

	

	return 0;

}

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

#include<cstdio>

#include<algorithm>

#include<cstring>

using namespace std;

const int maxn=998244353;

typedef long long ll;

int main()

{

	ll n,c,sum,ans;

	ll a[100006],vis[100006];

	scanf("%lld",&n);

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

	c=-1;

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

	{

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

		if(c<a[i])

		{

			c=a[i];

		}

	}

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

	{

		vis[a[i]]++;

		if(i==1)

		{

			if(a[i]>0)

			{

				printf("0\n");

				return 0;

			}

		}

		else

		{

			if(a[i]==0)

			{

				printf("0\n");

				return 0;

			}

		}

	}

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

	{

		if(i==1)

		{

			sum=1;

		}

		else

		{

			ans=1;

			for(ll j=1;j<=vis[i];j++)

			{

				ans=ans*vis[i-1]%maxn;

			}

			sum=sum*ans%maxn;

		}

	}

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

	return 0;

}

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

using namespace std;

typedef long long ll;

const int N=1E5+7;

ll arr[N];

const int MOD=998244353;

ll ksm(ll x, ll y){

	ll res=1;

	while(y){

		if(y&1) res=res*x%MOD;

		x=x*x%MOD;

		y>>=1;

	}

	return res%MOD;

}



int main(){

	ll n;

	cin>>n;

	ll sum=1;

	ll x;

	ll s=0;

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

		cin>>x;

		if(i==1&&x!=0) sum=0;

		arr[x]++;

		s=max(s,x);

	}

	for(int i=s;i>=0;i--){

		if(arr[i]==0) sum=0;

		if(i>1)	sum=sum*ksm(arr[i-1],arr[i])%MOD;

	}

	if(arr[0]>1) sum=0;

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

	

	return 0;

}

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

    #include <iostream>

    using namespace std;

     

    int main()

    {

      int N; cin >> N;

      long cnt[100005] = {};

      int D[100005] = {};

      int mx_D = 0;

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

      {

        cin >> D[i];

        mx_D = max(mx_D, D[i]);

        cnt[D[i]]++;

      }

      

      if (cnt[0] != 1 || D[0] != 0)

      {

        cout << 0 << endl;

        return 0;

      }

      

      long ans = 1;

      long mod = 998244353;

      

      for (int j = 1; j <= mx_D; j++)

      {

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

        {

          ans *= cnt[j - 1];

          ans %= mod;

        }

      }

      

      cout << ans << endl;

      return 0;

    }

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

    using namespace std;

    int main(){

    	int N,dir,D[100000]={0},maxD=0;

    	long long sum;

    	cin>>N>>dir;

    	if(dir!=0){

    		cout<<0;

    		return 0;

    	}

    	D[0]=1;

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

    		cin>>dir;

    		if(dir>maxD)maxD=dir;

    		D[dir]++;

    	}

    	if(D[0]!=1){

    		cout<<0;

    		return 0;

    	}

    	sum=D[0];

    	for(long i=2;i<=maxD;i++){

    		if(D[i]!=0){

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

    				sum*=D[i-1];

    				sum%=998244353LL;

    			}

    		}else{

    			sum=0;

    			break;

    		}

    	}

    	cout<<sum;

    	return 0;

    }

// Fastest known solution for this problem: