rt
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,y,b=0,c=0;
vector<int> a[10001];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i=1;i<=n;i++){
int x;
cin >> x;
if(x==1) b++;
else c++;
}
y=b-c;
if(y>0){
for(int i=0;i<=c;i++){
for(int j=0;j<=y;j++){
int cnt=0;
if(i&&j!=y) cnt+=a[i-1][j+1];
if(j) cnt+=a[i][j-1];
if(i||j) a[i].push_back(cnt%mod);
else a[i].push_back(1);
}
}
cout << a[c][y];
}
else{
for(int i=0;i<=1-y;i++){
for(int j=0;j<=b;j++){
int cnt=0;
if(i) cnt+=a[i-1][j];
if(j) cnt+=a[i][j-1];
if(i||j) a[i].push_back(cnt%mod);
else a[i].push_back(1);
}
}
cout << a[1-y][b];
}
return 0;
}