import sys

import numpy as np



n = int(eval(input()))

aaa = list(map(int, sys.stdin))

MOD = 998244353



s = sum(aaa)

dp1 = np.zeros(s + 1, dtype=np.int64)

dp2 = np.zeros(s + 1, dtype=np.int64)

dp1[0] = 1

dp2[0] = 1

for a in aaa:

    dp1a = np.roll(dp1, a)

    dp1 *= 2

    dp1 %= MOD

    dp1 += dp1a

    dp1 %= MOD



    dp2 += np.roll(dp2, a)

    dp2 %= MOD



h = (s + 1) // 2

ans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD

if s % 2 == 0:

    ans = (ans + dp2[h] * 3) % MOD

print(ans)

import sys

import numpy as np



n = int(eval(input()))

aaa = list(map(int, sys.stdin))

MOD = 998244353



s = sum(aaa)

dp1 = np.zeros(s + 1, dtype=np.int64)

dp2 = np.zeros(s + 1, dtype=np.int64)

dp1[0] = 1

dp2[0] = 1

for a in aaa:

    dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD

    dp2 = (dp2 + np.roll(dp2, a)) % MOD



h = (s + 1) // 2

ans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD

if s % 2 == 0:

    ans = (ans + dp2[h] * 3) % MOD

print(ans)

import sys
import numpy as np

n = int(eval(input()))
aaa = list(map(int, sys.stdin))
MOD = 998244353
s = sum(aaa)
dp1 = np.zeros(s + 1, dtype=np.int64)
dp2 = np.zeros(s + 1, dtype=np.int64)
dp1[0] = 1
dp2[0] = 1
for a in aaa:
    dp1a = np.roll(dp1, a)
    dp1 *= 2
    dp1 %= MOD
    dp1 += dp1a
    dp1 %= MOD
    dp2 += np.roll(dp2, a)
    dp2 %= MOD
h = (s + 1) // 2
ans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD
if s % 2 == 0:
    ans = (ans + dp2[h] * 3) % MOD
print(ans)

import sys
import numpy as np

n = int(eval(input()))
aaa = list(map(int, sys.stdin))
MOD = 998244353
s = sum(aaa)
dp1 = np.zeros(s + 1, dtype=np.int64)
dp2 = np.zeros(s + 1, dtype=np.int64)
dp1[0] = 1
dp2[0] = 1
for a in aaa:
    dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD
    dp2 = (dp2 + np.roll(dp2, a)) % MOD
h = (s + 1) // 2
ans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD
if s % 2 == 0:
    ans = (ans + dp2[h] * 3) % MOD
print(ans)

-    dp1a = np.roll(dp1, a) -    dp1 *= 2 -    dp1 %= MOD -    dp1 += dp1a -    dp1 %= MOD -    dp2 += np.roll(dp2, a) -    dp2 %= MOD +    dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD +    dp2 = (dp2 + np.roll(dp2, a)) % MOD