Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
numbers = [int(input()) for _ in range(N)]

M = 998244353
count_all = (3 ** N - 3 * (2 ** N - 2) - 3) % M

S = sum(numbers)
count3 = [[0 for _ in range(S + 1)] for _ in range(N)]
count3[0][0] = 2
count3[0][numbers[0]] = 1
count2 = [[0 for _ in range(S + 1)] for _ in range(N)]
count2[0][0] = 1
count2[0][numbers[0]] = 1

for i in range(1, N):
  for j in range(S + 1):
    if (count3[i - 1][j] > 0):
      count3[i][j + numbers[i]] += count3[i - 1][j]
      count3[i][j + numbers[i]] %= M
      count3[i][j] += 2 * count3[i - 1][j]
      count3[i][j] %= M
      count2[i][j + numbers[i]] += count2[i - 1][j]
      count2[i][j + numbers[i]] %= M
      count2[i][j] += count2[i - 1][j]
      count2[i][j] %= M

count_invalid = 0
for i in range(S):
  if (i > S / 2):
    count_invalid += count3[N - 1][i] - 2 * count2[N - 1][i]
    count_invalid %= M
if (S % 2 == 0):
  count_invalid += count3[N - 1][S // 2] - 2 * count2[N - 1][S // 2]
  count_invalid %= M

print((count_all - 3 * count_invalid) % M)


Fixed submission:
import numpy as np

N = int(input())
numbers = [int(input()) for _ in range(N)]

M = 998244353
count_all = (3 ** N - 3 * (2 ** N - 2) - 3) % M

S = sum(numbers)
count3 = np.zeros((N, S + 1), dtype=np.int64)
count3[0, 0] = 2
count3[0, numbers[0]] = 1
count2 = np.zeros((N, S + 1), dtype=np.int64)
count2[0, 0] = 1
count2[0, numbers[0]] = 1

for i in range(1, N):
    count3[i, numbers[i]:] += count3[i - 1, :-numbers[i]]
    count3[i, :] += 2 * count3[i - 1, :]
    count3[i, :] %= M
    count2[i, numbers[i]:] += count2[i - 1, :-numbers[i]]
    count2[i, :] += count2[i - 1, :]
    count2[i, :] %= M

invalid_from = S // 2 + 1
if (S % 2 == 0):
  invalid_from = S // 2
count_invalid = np.sum(count3[N - 1, invalid_from:-1]) - 2 * np.sum(count2[N - 1, invalid_from:-1])
count_invalid %= M

print((count_all - 3 * count_invalid) % M)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
numbers = [int(input()) for _ in range(N)]

M = 998244353
count_all = (3 ** N - 3 * (2 ** N - 2) - 3) % M

S = sum(numbers)
count3 = [[0 for _ in range(S + 1)] for _ in range(N)]
count3[0][0] = 2
count3[0][numbers[0]] = 1
count2 = [[0 for _ in range(S + 1)] for _ in range(N)]
count2[0][0] = 1
count2[0][numbers[0]] = 1

for i in range(1, N):
  for j in range(S + 1):
    if (count3[i - 1][j] > 0):
      count3[i][j + numbers[i]] += count3[i - 1][j]
      count3[i][j] += 2 * count3[i - 1][j]
      count2[i][j + numbers[i]] += count2[i - 1][j]
      count2[i][j] += count2[i - 1][j]

count_invalid = 0
for i in range(S):
  if (i > S / 2):
    count_invalid += count3[N - 1][i] - 2 * count2[N - 1][i]
if (S % 2 == 0):
  count_invalid += count3[N - 1][S // 2] - 2 * count2[N - 1][S // 2]

print((count_all - 3 * count_invalid) % M)


Fixed submission:
import numpy as np

N = int(input())
numbers = [int(input()) for _ in range(N)]

M = 998244353
count_all = (3 ** N - 3 * (2 ** N - 2) - 3) % M

S = sum(numbers)
count3 = np.zeros((N, S + 1), dtype=np.int64)
count3[0, 0] = 2
count3[0, numbers[0]] = 1
count2 = np.zeros((N, S + 1), dtype=np.int64)
count2[0, 0] = 1
count2[0, numbers[0]] = 1

for i in range(1, N):
    count3[i, numbers[i]:] += count3[i - 1, :-numbers[i]]
    count3[i, :] += 2 * count3[i - 1, :]
    count3[i, :] %= M
    count2[i, numbers[i]:] += count2[i - 1, :-numbers[i]]
    count2[i, :] += count2[i - 1, :]
    count2[i, :] %= M

invalid_from = S // 2 + 1
if (S % 2 == 0):
  invalid_from = S // 2
count_invalid = np.sum(count3[N - 1, invalid_from:-1]) - 2 * np.sum(count2[N - 1, invalid_from:-1])
count_invalid %= M

print((count_all - 3 * count_invalid) % M)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
numbers = [int(input()) for _ in range(N)]

M = 998244353
count_all = (3 ** N - 3 * (2 ** N - 2) - 3) % M

S = sum(numbers)
count3 = [0 for _ in range(S + 1)]
count3[0] = 2
count3[numbers[0]] = 1
count2 = [0 for _ in range(S + 1)]
count2[0] = 1
count2[numbers[0]] = 1

for i in range(1, N):
  count3_next = [0 for _ in range(S + 1)]
  count2_next = [0 for _ in range(S + 1)]
  for j in range(S + 1):
    if (count3[j] > 0):
      count3_next[j + numbers[i]] += count3[j]
      count3_next[j] += 2 * count3[j]
      count2_next[j + numbers[i]] += count2[j]
      count2_next[j] += count2[j]
  count3 = count3_next
  count2 = count2_next

count_invalid = 0
for i in range(S):
  if (i > S / 2):
    count_invalid += count3[i] - 2 * count2[i]
if (S % 2 == 0):
  count_invalid += count3[S // 2] - 2 * count2[S // 2]

print((count_all - 3 * count_invalid) % M)


Fixed submission:
import numpy as np

N = int(input())
numbers = [int(input()) for _ in range(N)]

M = 998244353
count_all = (3 ** N - 3 * (2 ** N - 2) - 3) % M

S = sum(numbers)
count3 = np.zeros((N, S + 1), dtype=np.int64)
count3[0, 0] = 2
count3[0, numbers[0]] = 1
count2 = np.zeros((N, S + 1), dtype=np.int64)
count2[0, 0] = 1
count2[0, numbers[0]] = 1

for i in range(1, N):
    count3[i, numbers[i]:] += count3[i - 1, :-numbers[i]]
    count3[i, :] += 2 * count3[i - 1, :]
    count3[i, :] %= M
    count2[i, numbers[i]:] += count2[i - 1, :-numbers[i]]
    count2[i, :] += count2[i - 1, :]
    count2[i, :] %= M

invalid_from = S // 2 + 1
if (S % 2 == 0):
  invalid_from = S // 2
count_invalid = np.sum(count3[N - 1, invalid_from:-1]) - 2 * np.sum(count2[N - 1, invalid_from:-1])
count_invalid %= M

print((count_all - 3 * count_invalid) % M)