n = int(input()) a = list(map(int,input().split())) dp = [0] * (2 * sum(a) + 1) dp[0] = 1 lendp = (2 * sum(a) + 1) mod = 998244353 for i in range(n): n_dp = [0] * (lendp) # print(dp) for j in range(lendp ): if dp[j] >= 0: n_dp[(j+a[i]) % lendp] = (n_dp[(j+a[i]) % lendp] + dp[j]) % mod n_dp[(j-a[i]) % lendp] = (n_dp[(j-a[i]) % lendp] + dp[j]) % mod dp = n_dp[::] ans = 0 for i in range(sum(a)): ans = (ans + (i+1) * dp[(i+1)] + (i+1) * dp[-(i+1)] ) % mod print(ans)