const MOD: usize = 998244353; 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 a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let summary = a.iter().sum::(); let mut dp = vec![vec![0usize; 2*summary+1]; n+1]; dp[0][summary] = 1; for i in 0..n { for j in 0..=2*summary { if dp[i][j] == 0 { continue; } dp[i+1][j-a[i]] += dp[i][j]; dp[i+1][j+a[i]] += dp[i][j]; dp[i+1][j-a[i]] %= MOD; dp[i+1][j+a[i]] %= MOD; } } let mut result = 0usize; for i in 0..=summary { result += i * dp[n][summary-i]; result += i * dp[n][summary+i]; result %= MOD; } println!("{}", result); }