Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
mod=998244353
S=sum(A)

dp=[0 for j in range(S+1)]
sub=[0 for j in range(S+1)]
dp[0]=pow(2,N,mod)
dp[A[0]]=pow(2,N-1,mod)
sub[0]=1
sub[A[0]]=1

for i in range(1,N):
    for j in range(S,-1,-1):
        dp[j]=(dp[j]+pow(2,mod-2,mod)*(j>=A[i])*dp[j-A[i]])%mod
        sub[j]=(sub[j]+(j>=A[i])*sub[j-A[i]])%mod

if S%2==1:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    print(ans)
else:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    ans+=3*sub[S//2]
    ans%=mod
    print(ans)

Fixed submission:
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
mod=998244353
inv=pow(2,mod-2,mod)
S=sum(A)

dp=[0 for j in range(S+1)]
sub=[0 for j in range(S+1)]
dp[0]=pow(2,N,mod)
dp[A[0]]=pow(2,N-1,mod)
sub[0]=1
sub[A[0]]=1

for i in range(1,N):
    for j in range(S,A[i]-1,-1):
        dp[j]=(dp[j]+inv*dp[j-A[i]])%mod
        sub[j]=(sub[j]+sub[j-A[i]])%mod

if S%2==1:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    print(ans)
else:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    ans+=3*sub[S//2]
    ans%=mod
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
mod=998244353
S=sum(A)

dp=[[0 for j in range(S+1)] for i in range(N)]
sub=[[0 for j in range(S+1)] for i in range(N)]
dp[0][0]=pow(2,N,mod)
dp[0][A[0]]=pow(2,N-1,mod)
sub[0][0]=1
sub[0][A[0]]=1

for i in range(1,N):
    for j in range(S+1):
        dp[i][j]=(dp[i-1][j]+pow(2,mod-2,mod)*(j>=A[i])*dp[i-1][j-A[i]])%mod
        sub[i][j]=(sub[i-1][j]+(j>=A[i])*sub[i-1][j-A[i]])%mod

if S%2==1:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[N-1][i]
        ans%=mod
    print(ans)
else:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[N-1][i]
        ans%=mod
    ans+=3*sub[N-1][S//2]
    ans%=mod
    print(ans)


Fixed submission:
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
mod=998244353
inv=pow(2,mod-2,mod)
S=sum(A)

dp=[0 for j in range(S+1)]
sub=[0 for j in range(S+1)]
dp[0]=pow(2,N,mod)
dp[A[0]]=pow(2,N-1,mod)
sub[0]=1
sub[A[0]]=1

for i in range(1,N):
    for j in range(S,A[i]-1,-1):
        dp[j]=(dp[j]+inv*dp[j-A[i]])%mod
        sub[j]=(sub[j]+sub[j-A[i]])%mod

if S%2==1:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    print(ans)
else:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    ans+=3*sub[S//2]
    ans%=mod
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
mod=998244353
S=sum(A)

dp=[[0 for j in range(S+1)] for i in range(N)]
dp[0][0]=pow(2,N,mod)
dp[0][A[0]]=pow(2,N-1,mod)

for i in range(1,N):
    for j in range(S+1):
        dp[i][j]=(dp[i-1][j]+pow(2,mod-2,mod)*(j>=A[i])*dp[i-1][j-A[i]])%mod

if S%2==1:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[N-1][i]
        ans%=mod
    print(ans)
else:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[N-1][i]
        ans%=mod
    dp=[[0 for j in range(S+1)] for i in range(N)]
    dp[0][0]=1
    dp[0][A[0]]=1

    for i in range(1,N):
        for j in range(S+1):
            dp[i][j]=(dp[i-1][j]+(j>=A[i])*dp[i-1][j-A[i]])%mod
    ans+=3*dp[N-1][S//2]
    ans%=mod
    print(ans)

Fixed submission:
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
mod=998244353
inv=pow(2,mod-2,mod)
S=sum(A)

dp=[0 for j in range(S+1)]
sub=[0 for j in range(S+1)]
dp[0]=pow(2,N,mod)
dp[A[0]]=pow(2,N-1,mod)
sub[0]=1
sub[A[0]]=1

for i in range(1,N):
    for j in range(S,A[i]-1,-1):
        dp[j]=(dp[j]+inv*dp[j-A[i]])%mod
        sub[j]=(sub[j]+sub[j-A[i]])%mod

if S%2==1:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    print(ans)
else:
    ans=pow(3,N,mod)
    for i in range((S+1)//2,S+1):
        ans-=3*dp[i]
        ans%=mod
    ans+=3*sub[S//2]
    ans%=mod
    print(ans)