#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let n = read::(); let a = read_vec::(); let max_sum = n * 100; let mut dp = vec![vec![vec![0i64; 101]; max_sum + 1]; n + 1]; dp[0][0][0] = 1; for aa in a { for prev_used in (0..n).rev() { for prev_sum in 0..max_sum { if prev_sum + aa > max_sum { break; } for prev_max in 0..=100 { dp[prev_used + 1][prev_sum + aa][max(prev_max, aa)] += dp[prev_used][prev_sum][prev_max]; } } } } let mut ans = 0; for used in 2..=n { let mut coef = 0; while coef <= used * 100 { let operated = coef / (used - 1); for prev_max in 0..=min(operated, 100) { ans += dp[used][coef][prev_max]; } coef += used - 1; } } println!("{}", ans); } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }