from sys import stdin n, *a = map(int, stdin.read().split()) p = 998244353 largenum = n * max(a) + 1 maxind = largenum * 2 dp = [[0 for i in range(maxind + 1)] for j in range(n+1)] dp[0][largenum] = 1 for i in range(n): for j in range(maxind + 1): if j >= a[i]: dp[i+1][j] = dp[i][j-a[i]] if j <= maxind - a[i]: dp[i+1][j] = (dp[i+1][j] + dp[i][j+a[i]]) % p ans = 0 for i in range(maxind+1): ans = (ans + abs(i-largenum) * dp[n][i] % p) % p print("{}".format(ans))