n = int(input()) a = list(map(int,input().split())) a.sort() ans = 0 sum_max = sum(a)+1 dp = [[0] * (sum_max) for _ in range(n+1)] dp[0][0] = 1 for i in range(1,n): max_ = a[i] ndp = [[0] * (sum_max) for _ in range(n+1)] for j in range(i+1): for k in range(sum_max): ndp[j][k] += dp[j][k] if j > 0 and dp[j-1][k] > 0: ndp[j][k+a[i-1]] += dp[j-1][k] if (max_*j)-k <= max_: if j > 0 and (k+ max_) % j == 0: ans += ndp[j][k] dp = ndp[::] print(ans)