M,z,s=998244353,1,0

N,*A=open(0)

d=[1]+[0]*7**6

e=[1]+[0]*7**6

for a in A:

 a=int(a);s+=a;i=s;z*=3

 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1

print(((z+~s%2*e[s//2]*3-3*sum(d[-~s//2:]))%M))
M,s=998244353,0

d=[1]+[0]*7**6

e=d[:]

n=eval(input())

for _ in'_'*n:

 a=eval(input());s+=a;i=s

 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1

print((3**n+~s%2*e[s//2]*3-3*sum(d[-~s//2:]))%M)
M, z, s = 998244353, 1, 0
N, *A = open(0)
d = [1] + [0] * 7**6
e = [1] + [0] * 7**6
for a in A:
    a = int(a)
    s += a
    i = s
    z *= 3
    while ~i:
        d[i] += d[i] + d[i - a] % M
        e[i] += e[i - a] % M
        i -= 1
print(((z + ~s % 2 * e[s // 2] * 3 - 3 * sum(d[-~s // 2 :])) % M))

M, s = 998244353, 0
d = [1] + [0] * 7**6
e = d[:]
n = eval(input())
for _ in "_" * n:
    a = eval(input())
    s += a
    i = s
    while ~i:
        d[i] += d[i] + d[i - a] % M
        e[i] += e[i - a] % M
        i -= 1
print((3**n + ~s % 2 * e[s // 2] * 3 - 3 * sum(d[-~s // 2 :])) % M)

-M, z, s = 998244353, 1, 0 -N, *A = open(0) +M, s = 998244353, 0 -e = [1] + [0] * 7**6 -for a in A: -    a = int(a) +e = d[:] +n = eval(input()) +for _ in "_" * n: +    a = eval(input()) -    z *= 3 -print(((z + ~s % 2 * e[s // 2] * 3 - 3 * sum(d[-~s // 2 :])) % M)) +print((3**n + ~s % 2 * e[s // 2] * 3 - 3 * sum(d[-~s // 2 :])) % M)