N = gets.chomp.to_i

a = []
sum = 0
for x in 0...N
  a[x] = gets.chomp.to_i
  sum += a[x]
end

ng = (sum+1)/2

arr = Array.new(N+1){ Array.new(300*N,0) }

arr[0][0] = 1
for i in 1..N*300
  arr[0][i] = 0
end

for t in 1..N
  for r in 0..N*t
    if r >= a[t-1]
      arr[t][r] = (arr[t-1][r-a[t-1]] + 2*arr[t-1][r]) % 998244353
    elsif
      arr[t][r] = (2*arr[t-1][r]) % 998244353
    end
  end
end

arr2 = Array.new(N+1){ Array.new(300*N,0) }

arr2[0][0] = 1
for i in 1..N*300
  arr2[0][i] = 0
end

for t in 1..N
  for r in 0..N*t
    if r >= a[t-1]
      arr2[t][r] = (arr2[t-1][r-a[t-1]] + arr2[t-1][r]) % 998244353
    elsif
      arr2[t][r] = (arr2[t-1][r]) % 998244353
    end
  end
end

c1 = 0
for x in ng..N*N
  c1 += arr[N][x]
end
c1 = c1 % 998244353 

c2 = 0
if sum % 2 == 0
  c2 = arr2[N][ng]
end

all = 1
for x in 1..N
  all *= 3
  all = all % 998244353 
end

answer = (all - c1*3 + c2*3 + 998244353) % 998244353 

puts answer