import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

immutable long MOD = 998244353;

void main() {
    auto N = readln.chomp.to!int;
    auto A = iota(N).map!(_ => readln.chomp.to!int).array;

    auto dp = new long[][][](2, 3, N*300+1);
    dp[0][0][0] = 1;

    int cur = 0;
    int tar = 1;

    foreach (i; 0..N) {
        foreach (j; 0..3) {
            dp[tar][j][] = 0;
        }
        foreach (j; 0..3) foreach (k; 0..N*300+1) if (dp[cur][j][k]) {
            (dp[tar][j][k+A[i]] += dp[cur][j][k]) %= MOD;
            if (j == 0) {
                (dp[tar][min(2, j+1)][k] += dp[cur][j][k] % MOD) %= MOD;
            } else if (j == 1) {
                (dp[tar][j][k] += dp[cur][j][k] % MOD) %= MOD;
                (dp[tar][min(2, j+1)][k] += dp[cur][j][k] % MOD) %= MOD;
            } else if (j == 2) {
                (dp[tar][min(2, j+1)][k] += dp[cur][j][k] * 2 % MOD) %= MOD;
            }
        }
        swap(cur, tar);
    }

    long ans = 0;
    int border = A.sum / 2 + A.sum % 2;

    foreach (k; border..N*300+1) {
        (ans += dp[cur][2][k] * 6) %= MOD;
    }

    ans = ((powmod(3, N, MOD) - ((powmod(2, N, MOD) - 2) * 3) - 3 - ans) % MOD + MOD) % MOD;
    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}
