Mod = 998244353
N,*A = `dd`.split.map &:to_i

S = A.inject(:+)

def cdp(m)
  dp = (0..N).map{ {} }
  dp[0][0] = 1
  (0...N).each{ |i|
    a = A[i]
    dpi = dp[i]
    dpii = dp[i+1]
    dpi.each{ |s,n|
      dpii[s+a] = ((dpii[s+a] || 0) + dpi[s]) % Mod
      dpii[s]   = ((dpii[s] || 0) + m*dpi[s]) % Mod
    }
  }
  dp[N]
end

z = 1
(0...N).each{ z = 3 * z % Mod }
Z = z

D1 = cdp(2)
X = ((S+1)/2..S).map{ |s| D1[s] || 0 }.inject(:+) % Mod
Y = (S % 2 == 0 ? cdp(1)[S/2] : 0) % Mod
p (Z - 3*(X - Y) + 3*(X - Y).abs * Mod) % Mod
#p "#{Z} - 3*(#{X} - #{Y})"
#p S, D1, Z, X, Y
