n = int(input()) cnt = sum(list(map(int, input().split()))) print(min(cnt, n - cnt) * pow(n, 998244351, 998244353) % 998244353)