program three_colors
  implicit none
  integer(8), parameter :: md = 998244353_8
  integer(8) :: x
  integer :: n, a, s, i, j, k
  logical :: dp(0:90000)
  dp = .false.
  dp(0) = .true.
  read(*,*) n
  s = 0
  do i = 1, n
    read(*,*) a
    s = s+a
    do j = s, a, -1
      if (dp(j-a)) dp(j) = .true.
    end do
  end do
  x = 0_8
  do i = s/2, s/4, -1
    if (.not.dp(i)) cycle
    do j = i, s/2-i, -1
      k = s-i-j
      if ((k.gt.i).or.(k.gt.j)) exit
      if (dp(k)) then
        if ((i.ne.j).and.(j.ne.k).and.(k.ne.i)) then
          x = x+6_8
        else if ((i.eq.j).and.(j.eq.k)) then
          x = x+1_8
        else
          x = x+3_8
        end if
      end if
    end do
    x = mod(x,md)
  end do
  write(*,'(i0)') x
  stop
end program three_colors