
MOD = 998244353
N = gets.to_i
A = N.times.map{ gets.to_i }
S = A.inject(&:+)

dp1 = Array.new(S + 1, 0)
dp2 = Array.new(S + 1, 0)

dp1[0] = 1
dp2[0] = 1


N.times.inject(0) do |sum, n|
  sum.downto(0) do |i|
    dp1[i] %= MOD
    dp2[i] %= MOD
    dp1[i + A[n]] += dp1[i]
    dp1[i] *= 2
    dp2[i + A[n]] += dp2[i]
  end
  sum + A[n]
end

ans = (3 ** N) % MOD

(0 .. S).each do |i|
  if i * 2 >= S
    ans -= dp1[i] * 3 + MOD*3
    ans %= MOD
  end
  if i * 2 == S
    ans += dp2[i] * 3
    ans %= MOD
  end
end
puts ans

