from collections import defaultdict n = int(input()) a = list(map(int, input().split())) dp = defaultdict(int) dp[(0, 0, 0)] = 1 for num in a: next_dp = defaultdict(int) # Copy existing entries (exclude current number) for key, count in dp.items(): next_dp[key] += count # Add entries where current number is included for (m, s, max_v), count in dp.items(): new_m = m + 1 new_s = s + num new_max = max(max_v, num) next_dp[(new_m, new_s, new_max)] += count dp = next_dp result = 0 for (m, s, max_v), count in dp.items(): if m >= 2: if (s % (m - 1)) == 0: required = s // (m - 1) if required >= max_v: result += count print(result)