import numpy as np



mod = 998244353

N = int(eval(input()))

a = np.array([int(eval(input())) for i in range(N)])

sum_a = np.sum(a)

dp = np.zeros((N+1, sum_a+1))

dp[0,0] = 1



for i in range(1, N+1):

    a_i = a[i-1]

    dp[i,a_i:] += dp[i-1,:-a_i]

    dp[i,:] += dp[i-1,:] * 2

    dp[i,:] %= mod



exc = np.sum(dp[N, (sum_a+1)//2:]) % mod

res = 3**N % mod - exc * 3



if sum_a % 2 == 0:

    dp = np.zeros((N+1, sum_a+1))

    dp[0,0] = 1

    for i in range(1, N+1):

        a_i = a[i-1]

        dp[i,a_i:] += dp[i-1,:-a_i]

        dp[i,:] += dp[i-1,:]

        dp[i,:] %= mod

    res += dp[N, sum_a//2] * 3



print((int(res % mod)))
import numpy as np



mod = 998244353

N = int(eval(input()))

a = np.array([int(eval(input())) for i in range(N)])

sum_a = np.sum(a)

dp = np.zeros((N+1, sum_a+1), dtype=np.int64)

dp[0,0] = 1



for i in range(1, N+1):

    a_i = a[i-1]

    dp[i,a_i:] += dp[i-1,:-a_i]

    dp[i,:] += dp[i-1,:] * 2

    dp[i,:] %= mod



exc = np.sum(dp[N, (sum_a+1)//2:]) % mod

res = 3**N % mod - exc * 3



if sum_a % 2 == 0:

    dp = np.zeros((N+1, sum_a+1), dtype=np.int64)

    dp[0,0] = 1

    for i in range(1, N+1):

        a_i = a[i-1]

        dp[i,a_i:] += dp[i-1,:-a_i]

        dp[i,:] += dp[i-1,:]

        dp[i,:] %= mod

    res += dp[N, sum_a//2] * 3



print((res % mod))
import numpy as np

mod = 998244353
N = int(eval(input()))
a = np.array([int(eval(input())) for i in range(N)])
sum_a = np.sum(a)
dp = np.zeros((N + 1, sum_a + 1))
dp[0, 0] = 1
for i in range(1, N + 1):
    a_i = a[i - 1]
    dp[i, a_i:] += dp[i - 1, :-a_i]
    dp[i, :] += dp[i - 1, :] * 2
    dp[i, :] %= mod
exc = np.sum(dp[N, (sum_a + 1) // 2 :]) % mod
res = 3**N % mod - exc * 3
if sum_a % 2 == 0:
    dp = np.zeros((N + 1, sum_a + 1))
    dp[0, 0] = 1
    for i in range(1, N + 1):
        a_i = a[i - 1]
        dp[i, a_i:] += dp[i - 1, :-a_i]
        dp[i, :] += dp[i - 1, :]
        dp[i, :] %= mod
    res += dp[N, sum_a // 2] * 3
print((int(res % mod)))

import numpy as np

mod = 998244353
N = int(eval(input()))
a = np.array([int(eval(input())) for i in range(N)])
sum_a = np.sum(a)
dp = np.zeros((N + 1, sum_a + 1), dtype=np.int64)
dp[0, 0] = 1
for i in range(1, N + 1):
    a_i = a[i - 1]
    dp[i, a_i:] += dp[i - 1, :-a_i]
    dp[i, :] += dp[i - 1, :] * 2
    dp[i, :] %= mod
exc = np.sum(dp[N, (sum_a + 1) // 2 :]) % mod
res = 3**N % mod - exc * 3
if sum_a % 2 == 0:
    dp = np.zeros((N + 1, sum_a + 1), dtype=np.int64)
    dp[0, 0] = 1
    for i in range(1, N + 1):
        a_i = a[i - 1]
        dp[i, a_i:] += dp[i - 1, :-a_i]
        dp[i, :] += dp[i - 1, :]
        dp[i, :] %= mod
    res += dp[N, sum_a // 2] * 3
print((res % mod))

-dp = np.zeros((N + 1, sum_a + 1)) +dp = np.zeros((N + 1, sum_a + 1), dtype=np.int64) -    dp = np.zeros((N + 1, sum_a + 1)) +    dp = np.zeros((N + 1, sum_a + 1), dtype=np.int64) -print((int(res % mod))) +print((res % mod))