Buggy python submission (verdict: Runtime Error):
iimport numpy as np
N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353
suma = sum(a)
memo = np.zeros((N+1, suma+1), dtype=np.int)
memo[0][0] = 1
memoe = np.zeros((N+1, suma+1), dtype=np.int)
memoe[0][0] = 1

ttl = 3
for i in range(N-1):
  ttl *=3
  ttl %= mod

for i in range(1, N+1):
  memotmp = memo[i-1]
  memotmpe = memoe[i-1]
  memotmp = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmp),axis=1)
  memotmpe = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmpe),axis=1)
  memo[i] = (memo[i-1]*2 + memotmp[:suma+1])%mod
  memoe[i] = (memoe[i-1] + memotmpe[:suma+1])%mod

ans = sum(memo[N][(suma-1)//2+1:])
if suma%2==0:
  ans -= memoe[N][suma/2]
  
print(((ttl - ans*3)%mod+mod)%mod)

Fixed submission:
import numpy as np
N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353
suma = sum(a)
memo = np.zeros((N+1, suma+1), dtype=np.int)
memo[0][0] = 1
memoe = np.zeros((N+1, suma+1), dtype=np.int)
memoe[0][0] = 1

ttl = 3
for i in range(N-1):
  ttl *=3
  ttl %= mod

for i in range(1, N+1):
  memotmp = memo[i-1]
  memotmpe = memoe[i-1]
  memotmp = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmp),axis=1)
  memotmpe = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmpe),axis=1)
  memo[i] = (memo[i-1]*2 + memotmp[:suma+1])%mod
  memoe[i] = (memoe[i-1] + memotmpe[:suma+1])%mod

ans = sum(memo[N][(suma-1)//2+1:])
if suma%2==0:
  ans -= memoe[N][suma/2]
  
print(((ttl - ans*3)%mod+mod)%mod)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353
suma = sum(a)
memo = [[0]*(suma+1) for _ in range(N+1)]
memo[0][0] = 1
memoe = [[0]*(suma+1) for _ in range(N+1)]
memoe[0][0] = 1

ttl = 3
for i in range(N-1):
  ttl *=3
  ttl %= mod

for i in range(1, N+1):
  memotmp = memo[i-1]
  memotmp = [0]*a[i-1] + memotmp
  for j in range(sum(a[:i])+1):
    memo[i][j] = (memo[i-1][j]*2 + memotmp[j])%mod
    memoe[i][j] = (memoe[i-1][j] + memotmp[j])%mod

ans = sum(memo[N][(suma-1)//2+1:])
if suma%2==0:
  ans -= memoe[N][suma/2]
  
print(((ttl - ans*3)%mod+mod)%mod)

Fixed submission:
import numpy as np
N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353
suma = sum(a)
memo = np.zeros((N+1, suma+1), dtype=np.int)
memo[0][0] = 1
memoe = np.zeros((N+1, suma+1), dtype=np.int)
memoe[0][0] = 1

ttl = 3
for i in range(N-1):
  ttl *=3
  ttl %= mod

for i in range(1, N+1):
  memotmp = memo[i-1]
  memotmpe = memoe[i-1]
  memotmp = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmp),axis=1)
  memotmpe = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmpe),axis=1)
  memo[i] = (memo[i-1]*2 + memotmp[:suma+1])%mod
  memoe[i] = (memoe[i-1] + memotmpe[:suma+1])%mod

ans = sum(memo[N][(suma-1)//2+1:])
if suma%2==0:
  ans -= memoe[N][suma/2]
  
print(((ttl - ans*3)%mod+mod)%mod)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353
suma = sum(a)
memo = [[0]*(suma+1) for _ in range(N+1)]
memo[0][0] = 1
memoe = [[0]*(suma+1) for _ in range(N+1)]
memoe[0][0] = 1

ttl = 3
for i in range(N-1):
  ttl *=3
  ttl %= mod
  
for i in range(N+1):
  for j in range(suma+1):
    if i==0:
      continue
    elif j - a[i-1]<0:
      memo[i][j]=(memo[i-1][j]*2)%mod
      memoe[i][j]=(memoe[i-1][j])%mod
    else:
      memo[i][j]=(memo[i-1][j]*2+memo[i-1][j-a[i-1]])%mod
      memoe[i][j]=(memoe[i-1][j]+memoe[i-1][j-a[i-1]])%mod

ans = sum(memo[N][(suma-1)//2+1:])
if suma%2==0:
  ans -= memoe[N][suma/2]
  
print(ttl - ans*3)

Fixed submission:
import numpy as np
N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353
suma = sum(a)
memo = np.zeros((N+1, suma+1), dtype=np.int)
memo[0][0] = 1
memoe = np.zeros((N+1, suma+1), dtype=np.int)
memoe[0][0] = 1

ttl = 3
for i in range(N-1):
  ttl *=3
  ttl %= mod

for i in range(1, N+1):
  memotmp = memo[i-1]
  memotmpe = memoe[i-1]
  memotmp = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmp),axis=1)
  memotmpe = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmpe),axis=1)
  memo[i] = (memo[i-1]*2 + memotmp[:suma+1])%mod
  memoe[i] = (memoe[i-1] + memotmpe[:suma+1])%mod

ans = sum(memo[N][(suma-1)//2+1:])
if suma%2==0:
  ans -= memoe[N][suma/2]
  
print(((ttl - ans*3)%mod+mod)%mod)