_ = gets.to_i
b = gets.split.map(&:to_i)
b.sort!
ans = 0
b.each_with_index do |b1, i|
  break unless b[i+2]
  (b.length-i).times do |n|
    (b.length-1-n).times do |m|
      break unless b[n+i+2+m]
      tmp = [ b1, b[i+n+1], b[n+i+2+m]].sort!
      tmp[0] + tmp[1] > tmp[2] ? ans += 1 : break
    end
  end
end
puts ans