local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

--
local function memoize(f)
    local cache = {}
    local function key(...)
        local args = {...}
        local k = tostring(args[1])
        for i=2,#args do
            k = k .. "*" .. tostring(args[i])
        end
        return k
    end
    return function(...)
        local k = key(...)
        if cache[k] then
            return cache[k]
        end
        local r = f(...)
        cache[k] = r
        return r
    end
end

-- returns (b^n) % m
local function modpow(b, n, m)
    if n == 0 then
        return 1
    elseif n % 2 == 0 then
        return modpow(b * b % m, n//2, m) % m
    else
        return b * modpow(b, n - 1, m) % m
    end
end

---
local MOD = 998244353
local N = io.read("n")
local a = {}
local S = 0
for i=1,N do
    a[i] = io.read("n")
    S = S + a[i]
end

local combh
combh = memoize(function(i, s)
    if i == 0 then
        if s == 0 then
            return 1
        else
            return 0
        end
    end
    --print(i, s, a[i])
    local r = combh(i - 1, s - a[i])
    r = r + combh(i - 1, s)
    return r % MOD
end)

-- ∑A = S/2 and ∑B = S/2 and ∑C = 0
local function getY()
    if S % 2 == 1 then
        return 0
    end
    return combh(N, S//2)
end

local combgeh
combgeh = memoize(function(i, s)
    if i == 0 then
        if s == 0 then
            return 1
        else
            return 0
        end
    end
    local r = combgeh(i - 1, s - a[i])
    r = r + (combgeh(i - 1, s) * 2) % MOD
    return r % MOD
end)

-- ∑A >= S/2
local function getX()
    local sum = 0
    for s = math.ceil(S/2), S, 1 do
        local c = combgeh(N, s)
        dbgpr("s,c", s, c)
        sum = (sum + c) % MOD
    end
    return sum
end

local X, Y = getX(), getY()
local Total = modpow(3, N, MOD)
dbgpr(Total, X, Y)
local ans = (Total - (3 * X) % MOD + (3 * Y) % MOD) % MOD
print(ans)
