a=gets.to_i
n=a.times.map { gets.to_i  }
@size = n.inject(:+)
a = 0
b = 0
c = 0

def f(n,a,b,c)
  i = 0
  return 0 if @size / 2.0 < [a,b,c].max
  if n == []
    if @size / 2.0 > [a,b,c].max
      return 1
    end
    return 0
  end
  i += f(n[1..-1],a + n[0],b,c)
  i += f(n[1..-1],a,b + n[0],c)
  i += f(n[1..-1],a,b,c + n[0])
  return i
end

puts f(n,a,b,c)
