N = gets.to_i
a = []
sum = 0
N.times do
  v = gets.to_i
  a << v
  sum += v
end
MOD = 998244353

all_pat = 1
N.times do
  all_pat *= 3
  all_pat %= MOD
end

dp = [1]
N.times do |i|
  next_dp = Array.new(dp.size + a[i], 0)
  dp.each_with_index do |num_pat, num_fill|
    # B,Cで塗る場合
    next_dp[num_fill] += 2 * num_pat
    next_dp[num_fill] %= MOD
    # Aで塗る場合
    next_dp[num_fill + a[i]] += num_pat
    next_dp[num_fill + a[i]] %= MOD
  end
  dp = next_dp
end

dp2 = [1]
N.times do |i|
  next_dp = Array.new(dp2.size + a[i], 0)
  dp2.each_with_index do |num_pat, num_fill|
    # Cで塗る場合は数えない
    # Bで塗る場合
    next_dp[num_fill] += num_pat
    next_dp[num_fill] %= MOD
    # Aで塗る場合
    next_dp[num_fill + a[i]] += num_pat
    next_dp[num_fill + a[i]] %= MOD
  end
  dp2 = next_dp
end

# p [all_pat, dp, dp2]
# 全パターンから三角形が成り立たないのを消す
calc = all_pat
start = (sum + 1)/2
dp[start..-1].each do |num_fill|
  calc += (MOD - num_fill) * 3
  calc %= MOD
end
# A=B, C=0 の場合は消しすぎなので戻す
if sum %2 == 0
  calc += dp2[sum/2] * 3
  calc %= MOD
end

puts calc
