N = gets.to_i
len = gets.strip.split.map(&:to_i)
newlen = len.sort
if N <= 2
  puts "0"
else
  cnt = 0
  for i in 0..N-3
    for j in i+1..N-2
      for k in j+1..N-1
        if newlen[k]+newlen[i]>newlen[j] && newlen[j]+newlen[k]>newlen[i] && newlen[i]+newlen[j]>newlen[k]
          cnt += 1
        end
      end
    end
  end
  puts cnt
end
