N = gets.to_i A = gets.split.map(&:to_i).sort dp = Array.new(N + 1) {Array.new(102) { Array.new(5010, 0) } } dp[0][0][0] = 1 ans = 0 A.each_with_index do |a, i| i.downto(0) do |j| (100 * i).downto(0) do |k| next if dp[i][j][k] == 0 dp[i + 1][j][k] += dp[i][j][k] nk = k + a m = j if m > 0 && nk % m == 0 c = nk / m if a <= c ans += dp[i][j][k] end end dp[i + 1][j + 1][nk] += dp[i][j][k] end end end puts ans