N = int(input()) A = list(map(int,input().split())) MOD = 998244353 M = sum(A) dp = [[0]*(2*M+1) for _ in range(N+1)] dp[0][M] = 1 for i in range(N): for j in range(2*M+1): if j-A[i] >= 0: if dp[i][j-A[i]] > 0: dp[i+1][j] += dp[i][j-A[i]] if j+A[i] < 2*M+1: if dp[i][j+A[i]] > 0: dp[i+1][j] += dp[i][j+A[i]] # dp[i+1][j] %= MOD ans = 0 for j in range(2*M+1): ans += dp[N][j]*abs(j-M) ans %= MOD print(ans)