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



a.sort(reverse=True)

cumsump1 = 1

s = sum(a)



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

dp[0] = 1

for ai in a:

    cumsump1 += ai

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

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

    dp %= modulo



ans = 3 ** n % modulo

ans -= 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



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



ans %= modulo



print(ans)

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
a.sort(reverse=True)
cumsump1 = 1
s = sum(a)
dp = np.zeros(s + 1, dtype=np.int)
dp[0] = 1
for ai in a:
    cumsump1 += ai
    dp[ai:cumsump1] = 2 * dp[ai:cumsump1] + dp[: -ai + cumsump1]
    dp[:ai] = 2 * dp[:ai]
    dp %= modulo
ans = 3**n % modulo
ans -= 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
    ans += 3 * dp[s // 2]
ans %= modulo
print(ans)

+a.sort(reverse=True) +cumsump1 = 1 -    dp[ai:] = 2 * dp[ai:] + dp[:-ai] +    cumsump1 += ai +    dp[ai:cumsump1] = 2 * dp[ai:cumsump1] + dp[: -ai + cumsump1] -sol = 3**n % modulo -sol -= 3 * dp[ceil(s / 2) :].sum() +ans = 3**n % modulo +ans -= 3 * dp[ceil(s / 2) :].sum() -    sol += 3 * dp[s // 2] -sol %= modulo -print(sol) +    ans += 3 * dp[s // 2] +ans %= modulo +print(ans)