fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let mut a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); a.sort(); let summary = a.iter().sum::(); let mut dp = vec![vec![vec![0usize; summary+1]; n+1]; n+1]; let mut result = 0usize; dp[0][0][0] = 1; for i in 0..n { for j in 0..n { for k in 0..=summary { if dp[i][j][k] == 0 { continue; } dp[i+1][j][k] += dp[i][j][k]; let sumval = k+a[i]; dp[i+1][j+1][sumval] += dp[i][j][k]; if j+1 >= 2 && sumval % j == 0 && sumval / j >= a[i] { result += dp[i][j][k]; } } } } println!("{}", result); }