from collections import defaultdict def main(): import sys input = sys.stdin.read().split() N = int(input[0]) A = list(map(int, input[1:N+1])) dp = defaultdict(int) dp[(0, 0, 0)] = 1 # (m, sum, max_e) : count for a in A: new_dp = defaultdict(int) for (m, s, e), cnt in dp.items(): # Not take a new_dp[(m, s, e)] += cnt # Take a new_m = m + 1 new_s = s + a new_e = max(e, a) new_dp[(new_m, new_s, new_e)] += cnt dp = new_dp total = 0 for (m, s, e), cnt in dp.items(): if m >= 2: divisor = m - 1 if divisor == 0: continue if s % divisor == 0: k = s // divisor if k >= e: total += cnt print(total) if __name__ == "__main__": main()