a=gets.to_i
n=a.times.map { gets.to_i  }
size = n.inject(:+)
a = []
b = []
c = []
def f(n,a,b,c)
  i = 0
  as = a.inject(:+).to_i
  bs = b.inject(:+).to_i
  cs = c.inject(:+).to_i
  ns = n.inject(:+).to_i
  return 0 if as + bs <= cs - ns || as + cs <= bs - ns || cs + bs <= as - ns
  if n == []
    if a!=[] && b!= [] && c!=[]
      if  as +bs > cs && as +cs > bs && cs +bs > as
        return 1
      end
      return 0
    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)
