#include #include #include using namespace std; using i64 = long long; using u64 = unsigned long long; using i32 = int; using u32 = unsigned int; #define rep(i,n) for(int i=0; i<(n); i++) int N; vector A; i64 dp[51][5101] = {}; // [count][sum] int main() { cin >> N; A.resize(N); rep(i,N) cin >> A[i]; sort(A.begin(), A.end()); int sumA = 0; for(auto a : A) sumA += a; i64 ans = 0; dp[0][0] = 1; for(auto a : A){ for(int c=N-1; c>=0; c--){ for(int s=sumA; s>=0; s--){ if(c >= 1 && (s+a)%c == 0 && a*c <= (s+a)){ // cout << "a = " << a << ", c = " << c << ", s = " << s << endl; ans += dp[c][s]; } dp[c+1][s+a] += dp[c][s]; } } } cout << ans << "\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;