require 'set'

n = gets.chomp.to_i
a = []
for i in 1..n do
    a.push(gets.chomp.to_i)
end

div = 998244353

s = 0
for i in 1..a.size do
    s += a[i-1]
end

num = 3 ** n
stack = Array.new(size = s+1,obj = 0)
last = Array.new(size = s+1,obj = 0)
stack[0] += 1
last[0] += 1
sum = 0
tar = Set.new([0])
for i in 1..n do
    pos = a[i-1]
    addset = []
    tar.each do |ai|
        stack[ai] += last[ai]
        j = ai+pos
        stack[j] += last[ai]
        addset.push(j)
    end
    tar.merge(addset)
    last = Marshal.load(Marshal.dump(stack))
    # p tar
    # p stack
end

cnt = 0
start = s/2
if s.odd? 
    start += 1
end
for i in start..s do
    cnt += stack[i]
end

ev = 0
if (s.even?)
    ev = stack[s/2]
end
pattern = 3 ** (n) -3*cnt +3*ev 

p pattern % div