fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = Array(n) {
        readLine()!!.toInt()
    }
    val suma = a.sum()
    val suma2 = suma / 2
    val mod = 998244353L
    val dp1 = Array(suma2 + 1) { i ->
        if (i == 0) 3L else 0L
    }
    val dp2 = Array(suma2 + 1) { i ->
        if (i == 0) 3L else 0L
    }
    a.map { ai ->
        (suma2 downTo ai).map { j ->
            dp1[j] = (dp1[j] + dp1[j - ai] * 2) % mod
            dp2[j] = (dp2[j] + dp2[j - ai]    ) % mod
        }
    }
    val pow3 = (1 .. n).fold(1L) { x, dummy ->
        (x * 3) % mod
    }
    val ret = dp1.fold(pow3) { x, dp ->
        (x + mod - dp) % mod
    }
    val half = if (suma % 2 == 0) dp2[suma2] else 0
    print("${(ret + half) % mod}")
}