import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

enum MOD = 10 ^^ 9 + 7;

void main()
{
    // <全体> - <S/2 <= R> * 3 + <S/2 == R == G (B == 0)> * 3
    immutable MOD = 998244353;
    long N = lread();
    long[] A;
    foreach (_; 0 .. N)
        A ~= lread();

    long s = A.sum();
    // writeln(s);
    long all = powmod(3, N, MOD);
    // writeln(all);

    auto dp1 = new long[][](N + 1, s * 2); // dp[i][j] = iまで選んでRがjになる組み合わせ
    // dp1[1][A[0]] = 1;
    dp1[0][0] = 1;
    foreach (i; 0 .. N)
        foreach (j; 0 .. s)
        {
            dp1[i + 1][j] = (dp1[i + 1][j] + dp1[i][j] * 2) % MOD; // Rに採用しなかったものをGかBに割り振る2通り
            dp1[i + 1][j + A[i]] = (dp1[i + 1][j + A[i]] + dp1[i][j]) % MOD;
        }
    long ans_dp1 = dp1[N][(s + 1) / 2 .. $].sum();
    // writeln(ans_dp1 * 3);

    auto dp2 = new long[][](N + 1, s * 2); // dp[i][j] = iまで選んでRがj、Gが0になる組み合わせ
    dp2[0][0] = 1;
    foreach (i; 0 .. N)
        foreach (j; 0 .. s)
        {
            dp2[i + 1][j] = dp2[i + 1][j] + dp2[i][j] % MOD;
            dp2[i + 1][j + A[i]] = dp2[i + 1][j + A[i]] + dp2[i][j] % MOD;
        }
    long ans_dp2 = (s & 1) ? 0 : dp2[N][s / 2];
    // writeln(ans_dp2 * 3);
    long ans = all - ans_dp1 * 3 + ans_dp2 * 3;
    if (ans < 0)
        ans += MOD;
    writeln(ans);
}

long powmod(long x, long n, long m)
{
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1, m) % m;
    }
    long tmp = powmod(x, n / 2, m);
    return tmp * tmp % m;
}
