#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
#define P 998244353
const int N=1000005;
int n,a[N],f[2][105][10005],fac[N];
il void add(it &p,ct q){p+=q,p>=P?p-=P:0;}
int main(){ 
	scanf("%d",&n);it i,j,sum=0,ans=0;
	for(i=fac[0]=1;i<=n;++i) scanf("%d",&a[i]),sum+=a[i],fac[i]=(0ll+fac[i-1])*i%P;
	std::sort(a+1,a+1+n);
	if(sum&1) return puts("0"),0;
	if(a[n]>sum/2) return puts("0"),0;
	sum>>=1,f[0][0][0]=1;
	//for(i=0;i<=n;++i) f[i][0][0]=1;
	for(i=1;i<=n;++i){
		memset(f[i&1],0,sizeof(f[i&1]));
		for(it k=0;k<=n;++k)
			for(j=0;j<=sum;++j)
				f[i&1][k][j]=f[(i-1)&1][k][j],a[i]<=j?add(f[i&1][k][j],f[(i-1)&1][k-1][j-a[i]]),0:0;
	}
//	for(i=1;i<=n;++i) printf("%d ",f[n&1][i][sum]);puts("");
	for(i=1;i<=n;++i) ans=(ans+(0ll+f[n&1][i][sum])*fac[i]%P*fac[n-i])%P;
	printf("%d",ans);
	return 0;
}

#include "bits/stdc++.h"
using namespace std;
 
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
#define uwu ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize("Ofast")
 
const int INF = 1e9 + 7;
const long long INF2 = 1e17;

int main(void) {
	uwu
	
	int n, m; cin >> n >> m;
	vector <string> v(n); 
	ffor(n) cin >> v[i];
	
	const int mod = 998244353;
	long long ans = 1;
	
	for(int i = 0, j = 0; i != n - 1 || j != m - 1; ) {
		set <char> colours;
		for(int x = i, y = j; 0 <= x && x < n && 0 <= y && y < m; x++, y--) {
			if (v[x][y] != '.') colours.insert(v[x][y]);
		}
		if ((int)colours.size() == 0) {
			ans *= 2;
			ans %= mod;
		}
		else if ((int)colours.size() == 1) {
		}
		else if ((int)colours.size() == 2) {
			cout << 0 << '\n';
			return 0;
		}
		
		if (j == m - 1) i++;
		else j++;
	}
	if (v[n - 1][m - 1] == '.') ans *= 2;
	ans %= mod;
	cout << ans << '\n';
}

/*
C:\Users\kenne\OneDrive\Desktop\competitive_programming\main.cpp
*/
