n = gets.chomp.to_i
ls = gets.chomp.split.map(&:to_i)
ans = 0
ls.combination(3) do |try|
    if try[0] < try[1] + try[2] && try[1] < try[0] + try[2] && try[2] < try[1] + try[0]
        ans += 1
    end
end
puts ans
