module mod_three_colors
  implicit none
  integer(8), parameter :: md = 998244353_8
contains
  recursive function pow(a,b) result(r)
    implicit none
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer(8) :: r
    r = 1_8
    if (b.eq.0) return
    if (mod(b,2).eq.0) then
      r = pow(a,b/2)
      r = mod(r*r,md)
      return
    end if
    r = mod(a*pow(a,b-1),md)
    return
  end function pow
end module mod_three_colors
program three_colors
  use mod_three_colors
  implicit none
  integer :: n, a, s, i, j
  integer(8) :: x, dp1(0:90000), dp2(0:90000)
  dp1 = 0_8
  dp2 = 0_8
  read(*,*) n
  s = 0
  dp1(0) = 1_8
  dp2(0) = 1_8
  do i = 1, n
    read(*,*) a
    do j = s, 0, -1
      dp1(j+a) = mod(dp1(j+a)+dp1(j),md)
      dp1(j) = mod(2_8*dp1(j),md)
      dp2(j+a) = mod(dp2(j+a)+dp2(j),md)
    end do
    s = s+a
  end do
  x = pow(3_8,n)+md-mod(3_8*sum(dp1((s+1)/2:s)),md)
  if (mod(s,2).eq.0) x = x+3_8*dp2(s/2)
  x = mod(x,md)
  write(*,'(i0)') x
  stop
end program three_colors