#include using namespace std; //#include //using namespace atcoder; using ll = long long int; using ull = unsigned long long int; using ld = long double; constexpr ll MAX = 2000000000000000000; constexpr ld PI = 3.14159265358979; constexpr ll MOD = 998244353;//2024948111; ld dotorad(ld K){ return PI * K / 180.0; } ld radtodo(ld K){ return K * 180.0 / PI; } mt19937 mt; void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); } vector fac,finv,inv; void COMinit(ll n = 1000000){ fac.resize(n); finv.resize(n); inv.resize(n); inv[1] = 1; fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; ll i; for(i = 2;i < n;i++){ fac[i] = (fac[i - 1] * i) % MOD; inv[i] = MOD - ((inv[MOD % i] * (MOD / i)) % MOD); finv[i] = (finv[i - 1] * inv[i]) % MOD; } } ll COM(ll n,ll m){ //nCm if(n < m) return 0; if(n < 0 || m < 0) return 0; return (fac[n] * (finv[m] * finv[n - m] % MOD)) % MOD; } ll f(ll a,ll b){ return COM(a + b,a); } int main(){ COMinit(); ll N,a = 0; cin >> N; vector A(N); for(ll i = 0; i < N; i++){ cin >> A[i]; a += A[i]; } a = min(a,N - a); cout << (a * inv[N]) % MOD << endl; }