#include void merge_sort(int n, int x[]) { static int y[51] = {}; if (n <= 1) return; merge_sort(n / 2, &(x[0])); merge_sort((n + 1) / 2, &(x[n/2])); int i, p, q; for (i = 0, p = 0, q = n / 2; i < n; i++) { if (p >= n / 2) y[i] = x[q++]; else if (q >= n) y[i] = x[p++]; else y[i] = (x[p] < x[q])? x[p++]: x[q++]; } for (i = 0; i < n; i++) x[i] = y[i]; } int main() { int i, N, A[51]; scanf("%d", &N); for (i = 0; i < N; i++) scanf("%d", &(A[i])); merge_sort(N, A); int j, k, sum; long long dp[51][5001] = {}, ans = 0; for (i = 1, sum = A[0], dp[0][0] = 1, dp[1][A[0]] = 1; i < N; i++) { for (j = 1; j <= i; j++) for (k = A[i] * (j - 1); k <= sum; k++) if ((k + A[i]) % j == 0) ans += dp[j][k]; for (j = i; j >= 0; j--) for (k = sum; k >= 0; k--) dp[j+1][k+A[i]] += dp[j][k]; sum += A[i]; } printf("%lld\n", ans); fflush(stdout); return 0; }