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])) # Initialize DP: dp[m] is a dictionary of (sum, max_val) -> count dp = [defaultdict(int) for _ in range(N+2)] # m ranges from 0 to N dp[0][(0, 0)] = 1 # base case: 0 elements, sum 0, max 0 for a in A: # Create a temporary structure to hold new states temp = [defaultdict(int) for _ in range(N+2)] for m in range(N+1): for (s, curr_max), cnt in dp[m].items(): # Take the current element a new_m = m + 1 if new_m > N: continue new_s = s + a new_max = max(curr_max, a) temp[new_m][(new_s, new_max)] += cnt # Merge the temp into dp for m in range(N+1): for (s_max, cnt) in temp[m].items(): s, max_val = s_max dp[m][(s, max_val)] += cnt ans = 0 for m in range(2, N+1): for (s, max_val), cnt in dp[m].items(): if (m - 1) == 0: continue # impossible since m >=2 if s % (m - 1) != 0: continue k = s // (m - 1) if max_val <= k: ans += cnt print(ans) if __name__ == '__main__': main()