function canBuild(a, b, c) {
    return (a + b > c && b + c > a && c + a > b);
}

function check(r, g, b, As, index, memo) {
    if (As.length == index) {
        return canBuild(r, g, b) ? 1 : 0;
    } else {
        var rgb = [r, g, b];
        rgb.sort((a, b) => { return a - b; });
        var key = "" + rgb[0] + "-" + rgb[1] + "-" + rgb[2] + "-" + index;
        if (typeof memo[key] != "undefined") {
            return memo[key];
        } else {
            const a = As[index];
            var result = (
                check(r + a, g, b, As, index + 1, memo) 
            + check(r, g + a, b, As, index + 1, memo) 
            + check(r, g, b + a, As, index + 1, memo));
            memo[key] = result;
            return result;
        }
    }
}

function Main(input) {
    const N = parseInt(input[0])
    var As = [];
    input.slice(1).forEach(element => {
        const value = parseInt(element);
        As.push(value);
    });
    var memo = {};

    console.log((check(As[0], 0, 0, As, 1, memo) * 3) % 998244353);
}

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));