#include namespace { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic pop using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template void chmax(T& a, const T& b) { a = max(a, b); } template void chmin(T& a, const T& b) { a = min(a, b); } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using mint = modint998244353; mint dp[51][5001]; } int main() { ios::sync_with_stdio(false); cin.tie(0); dp[0][0] = 1; int n; cin >> n; VI a(n); rep(i, n) cin >> a[i]; sort(all(a)); mint ans; for (int x: a) { rrep(k, n) rrep(s, 5001) if (dp[k][s] != mint()) { int nk = k + 1, ns = s + x; if (nk > 1 && (x == 0 || (ns % (nk - 1) == 0 && x <= ns / (nk - 1)))) { ans += dp[k][s]; } dp[nk][ns] += dp[k][s]; } } cout << ans.val() << endl; }