#include #include using namespace std; const int N = 105, mod = 998244353; int n, s[N], f[N][N][N], dp[N][N]; int add(int x, int y) { return x + y < mod ? x + y : x + y - mod; } int sub(int x, int y) { return x < y ? x + mod - y : x - y; } int query(int x) { int y = 1, r = 0; for (int i = x - 1; i; i--) { if (y <= s[i]) r += s[i] - y; else y = 2 * y - s[i]; if (y > n) return n + 1; } return max(0, y - r - s[0]); } 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, s[x]++; } f[101][0][0] = 1; for (int i = 100; i; i--) { for (int j = 0; j <= s[i]; j++) { int x = s[i] - j; for (int k = 0; k <= n; k++) { if (k >= x) { if (k + k - x <= n) { for (int t = 0; t <= n; t++) f[i][2 * k - x][t] = add(f[i][2 * k - x][t], f[i + 1][k][t]); } } else { for (int t = 0; t + x - k <= n; t++) f[i][k][t + x - k] = add(f[i][k][t + x - k], f[i + 1][k][t]); } } } for (int j = 1; j <= n / i; j++) { for (int k = 0; 2 * k + j <= n; k++) for (int t = 0; t <= n; t++) f[i][2 * k + j][t] = add(f[i][2 * k + j][t], f[i + 1][k][t]); } } int ans = mod - 1; for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) for (int k = max(0, i + j - s[0]); k <= n; k++) ans = add(ans, f[1][j][k]); dp[101][0] = 1; for (int i = 100; i; i--) for (int j = 0; j <= n; j++) for (int x = 0; x <= s[i] && x + j <= n; x++) dp[i][j + x] = add(dp[i][j + x], dp[i + 1][j]); for (int i = 1; i <= 100; i++) if (s[i]) { int t = query(i); for (int x = 0; x != s[i]; x++) for (int j = 0; j < t - 1 - x; j++) ans = sub(ans, dp[i + 1][j]); } if (!s[0]) for (int i = 1; i <= 100; i++) if (s[i]) { if (query(i) > 1) ans = add(ans, 1); break; } cout << ans; }