import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {

  // (x ^ n) % mod
  def repeatSquares(x: Long, n: Int, mod: Int): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % mod, n/2, mod)
    else
      (x * repeatSquares(x*x % mod, n/2, mod)) % mod
  }


  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val a = new Array[Int](N+1)
  for (i <- 1 to N)
    a(i) = in.next().toInt


  //
  val MOD = 998244353

  val max = a.sum
  val dp = Array.ofDim[Int](N+1, max+1)
  for (i <- 0 to N; sum <- 0 to max)
    dp(i)(sum) = -1
  dp(0)(0) = 1

  for (i <- 1 to N; sum <- 0 to max) {
    if (sum - a(i) >= 0) {
      if (dp(i-1)(sum) >= 0) {
        dp(i)(sum) = dp(i-1)(sum) * 2 + Math.max(0, dp(i-1)(sum-a(i)))
      }
      else
        dp(i)(sum) = dp(i-1)(sum-a(i))
    }
    else if (dp(i-1)(sum) >= 0)
      dp(i)(sum) = dp(i-1)(sum) * 2

    dp(i)(sum) %= MOD
  }

  var ans = 0L
  for (i <- max / 2 + 1 to max) {
    ans += dp(N)(i)
    ans %= MOD
  }

  ans = repeatSquares(3, N, MOD) - ans * 3
  ans = (ans + MOD) % MOD
  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
