m=998244353 n,*c=map(int,open(0).read().split()) c=sum(c) print(min(c,n-c)*pow(n,m-2,m)%m)