#![allow(non_snake_case)] use proconio::{input}; mod mod_int { use core::iter::Sum; use core::ops::*; #[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)] pub struct ModInt { value: i32 } impl ModInt { fn normalize(v: i64) -> i32 { if 0 <= v && v < MOD as i64 { v as i32 } else { let v1 = (v % MOD as i64) as i32; if v1 < 0 { v1 + MOD } else { v1 } } } pub fn new(v: i64) -> ModInt { ModInt{ value: Self::normalize(v) } } pub fn inverse(self) -> Self { let mut x = MOD as i64; let mut y = self.value as i64; let mut p = 1; let mut q = 0; let mut r = 0; let mut s = 1; while y != 0 { let u = x / y; let x0 = y; y = x - y * u; x = x0; let r0 = p - r * u; let s0 = q - s * u; p = r; r = r0; q = s; s = s0; } ModInt::new(q) } } impl std::fmt::Display for ModInt { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.value) } } impl Add for ModInt { type Output = Self; fn add(self, rhs: Self) -> Self { let value = self.value as i64 + rhs.value as i64; let value = (if value < MOD as i64 { value } else { value - MOD as i64 }) as i32; ModInt{ value } } } impl Add for ModInt { type Output = Self; fn add(self, rhs: i64) -> Self { self + ModInt::new(rhs) } } impl Sub for ModInt { type Output = Self; fn sub(self, rhs: Self) -> Self { let value = self.value as i64 - rhs.value as i64; let value = (if value >= 0 { value } else { value + MOD as i64 }) as i32; ModInt{ value } } } impl Sub for ModInt { type Output = Self; fn sub(self, rhs: i64) -> Self { self - ModInt::new(rhs) } } impl AddAssign for ModInt { fn add_assign(&mut self, rhs: Self) { *self = *self + rhs } } impl AddAssign for ModInt { fn add_assign(&mut self, rhs: i64) { *self = *self + rhs } } impl Mul for ModInt { type Output = Self; fn mul(self, rhs: Self) -> Self { Self::new(self.value as i64 * rhs.value as i64) } } impl MulAssign for ModInt { fn mul_assign(&mut self, rhs: Self) { *self = *self * rhs } } impl Div for ModInt { type Output = Self; fn div(self, rhs: Self) -> Self { self * rhs.inverse() } } impl Div for ModInt { type Output = Self; fn div(self, rhs: i64) -> Self { self / ModInt::new(rhs) } } impl Sum for ModInt { fn sum>(iter: I) -> Self { iter.fold(Self::new(0), |a, b| a + b) } } } const MOD: i32 = 998244353; type MInt = mod_int::ModInt::; fn main() { input!{ n: usize, a: [i32; n] } let s: MInt = a.iter().map(|x| MInt::new(*x as i64)).sum::<_>(); println!("{}", s / n as i64) }