N = gets.to_i
num = gets.strip.split.map(&:to_i)
if N <= 2 then
  puts 0
else
  cnt = 0
  for i in 0..(N-3)
    for k in (i+1)..(N-2)
      for j in (k+1)..(N-1)
        new =[num[i],num[k],num[j]].map(&:to_i)
        if 2*new.max < new.sum then
         cnt += 1
        end
      end
    end
  end
  puts cnt
end

