#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<ctime>
#include<map>
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
const ll mod = 998244353;
const int maxn = 101001;
ll a[maxn];
ll mul(ll x,ll y,ll z)
{
    ll sm = (ld)x/z*y;
    return ((ull)x*y-(ull)sm*z+z)%z;
}
ll qpow(ll x,ll y,ll z)
{
    ll ans = 1;
    x %= z;
    for(ll i=y;i;i>>=1){
        if(i&1) ans = mul(ans,x,z);
        x = mul(x,x,z);
    }
    return ans%z;
}
int main(void)
{
    int n,x;
    scanf("%d",&n);
    cin>>x;	//判断首位是否为0
    if(x!=0){
        printf("0\n");
        return 0;
    }
    a[x]++;
    for(int i=1;i<n;i++){
        scanf("%d",&x);
        a[x]++;
    }
    if(a[0]>1){	//判断是否多个0
        printf("0\n");
        return 0;
    }
    int ret = 0;
    ll ans = 1,pr = 1;
    for(int i=0;i<n;i++){
        if(a[i]==0){	//判断是否有间隔
            if(ret!=n)  ans = 0;
            break;
        }
        ans = mul(ans,qpow(pr,a[i],mod),mod);
        pr = a[i];
        ret += (int)a[i];
    }
    printf("%lld\n",ans);
    return 0;
}
