mod = 998244353 N = int(input()) A = list(map(int, input().split())) S = A.count(1) if S * 2 <= N: print(S * pow(N, mod-2, mod) % mod) else: print((N - S) * pow(N, mod-2, mod) % mod)