#include #include using namespace std; using modint = atcoder::modint998244353; const int SZ = 105; modint dp[SZ][SZ][SZ]; int main(){ int N; cin >> N; vector S(N); for(int i = 0; i < N; i++){ cin >> S[i]; } sort(S.begin(), S.end()); vector C(SZ); for(int i = 0; i < N; i++){ C[S[i]]++; } memset(dp, 0, sizeof(dp)); dp[SZ - 1][0][0] = 1; modint ans = 0; for(int i = SZ - 2; i >= 0; i--){ int require = 0; vectorf(i + 1); f[max(0, i - 1)] = 1; for(int j = i - 1; j >= 1; j--){ int use = min(f[j], C[j]); f[j - 1] = 2 * f[j] - use; f[j - 1] = min(f[j - 1], SZ); require -= C[j] - use; } require += f[0]; for(int j = 0; j < SZ; j++){ for(int k = 0; k < SZ; k++){ for(int num = 0; num < SZ; num++){ int use = min(j + num, C[i]); int nj = 2 * j + num - use; int nk = k + C[i] - use; if(i == 0 && nj > 0 && j + num <= C[i] + k){ ans += dp[i+1][j][k]; } if(nj < SZ && nk < SZ){ dp[i][nj][nk] += dp[i+1][j][k]; } if((nk != 0 || S[0] != i) && nj == 0 && num > 0 && nk >= require - 1){ ans += dp[i+1][j][k]; } } } } } cout << ans.val() + 1<< endl; }