import numpy as np

from math import ceil



n = int(eval(input()))

a = [int(eval(input())) for _ in range(n)]

modulo = 998244353



s = sum(a)



dp = np.zeros(s + 1, dtype=np.int)

dp[0] = 1

for ai in a:

    dp[ai:] = 2 * dp[ai:] + dp[:-ai]

    dp[:ai] = 2 * dp[:ai]

    dp %= modulo

sol = 3 ** n % modulo

sol -= 3 * dp[ceil(s / 2) :].sum()





if s % 2 == 0:

    dp = np.zeros(s + 1, dtype=np.int)

    dp[0] = 1

    for ai in a:

        dp[ai:] = dp[ai:] + dp[:-ai]

        dp %= modulo



    sol += 3 * dp[s // 2]



sol %= modulo



print(sol)

import numpy as np

from math import ceil



n = int(eval(input()))

a = [int(eval(input())) for _ in range(n)]

modulo = 998244353



s = sum(a)



dp = np.zeros(s + 1, dtype=np.int)

dp[0] = 1

for ai in a:

    dp[ai:] = 2 * dp[ai:] + dp[:-ai]

    dp[:ai] = 2 * dp[:ai]

    dp %= modulo



sol = 3 ** n % modulo

sol -= 3 * dp[ceil(s / 2) :].sum()



if s % 2 == 0:

    dp = np.zeros(s // 2 + 1, dtype=np.int)

    dp[0] = 1

    for ai in a:

        dp[ai:] = (dp[ai:] + dp[:-ai]) % modulo



    sol += 3 * dp[s // 2]



sol %= modulo



print(sol)

import numpy as np
from math import ceil

n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
modulo = 998244353
s = sum(a)
dp = np.zeros(s + 1, dtype=np.int)
dp[0] = 1
for ai in a:
    dp[ai:] = 2 * dp[ai:] + dp[:-ai]
    dp[:ai] = 2 * dp[:ai]
    dp %= modulo
sol = 3**n % modulo
sol -= 3 * dp[ceil(s / 2) :].sum()
if s % 2 == 0:
    dp = np.zeros(s + 1, dtype=np.int)
    dp[0] = 1
    for ai in a:
        dp[ai:] = dp[ai:] + dp[:-ai]
        dp %= modulo
    sol += 3 * dp[s // 2]
sol %= modulo
print(sol)

import numpy as np
from math import ceil

n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
modulo = 998244353
s = sum(a)
dp = np.zeros(s + 1, dtype=np.int)
dp[0] = 1
for ai in a:
    dp[ai:] = 2 * dp[ai:] + dp[:-ai]
    dp[:ai] = 2 * dp[:ai]
    dp %= modulo
sol = 3**n % modulo
sol -= 3 * dp[ceil(s / 2) :].sum()
if s % 2 == 0:
    dp = np.zeros(s // 2 + 1, dtype=np.int)
    dp[0] = 1
    for ai in a:
        dp[ai:] = (dp[ai:] + dp[:-ai]) % modulo
    sol += 3 * dp[s // 2]
sol %= modulo
print(sol)

-    dp = np.zeros(s + 1, dtype=np.int) +    dp = np.zeros(s // 2 + 1, dtype=np.int) -        dp[ai:] = dp[ai:] + dp[:-ai] -        dp %= modulo +        dp[ai:] = (dp[ai:] + dp[:-ai]) % modulo