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)
if s.even?
    harf = Array.new(size = s+1, obj = 0)
    last2 = Array.new(size = s+1, obj = 0)
    harf[0] += 1
    last2[0] += 1
end
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]
        if s.even?
            harf[j] += last2[ai]
        end
        addset.push(j)
    end
    tar.merge(addset)
    last = Marshal.load(Marshal.dump(stack))
    if s.even?
        last2 = Marshal.load(Marshal.dump(harf))
    #     p harf    
    end
    # 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 = harf[s/2]
end
pattern = 3 ** (n) -3*cnt +3*ev 
# print n," ",cnt," ",ev,"\n"
p pattern % div