N = gets.chomp.to_i
L_ARR = gets.chomp.split(" ").map{|s| s.to_i }.sort

count = 0
(N-2).times do |i|
  a = L_ARR[i]
  n = 2+i
  (N-i-2).times do |j|
    b = L_ARR[j+i+1]
    max_length = a + b
    if n == N-1 && L_ARR[n] < max_length
	  count += n-(i+j+1) 
      next
    end
    (N-n).times do |k|
      c = L_ARR[n+k]
      if n+k == N-1 && c < max_length
        count += n+k-(j+i+1)
        n = n+k
        break
      elsif c >= max_length
        count += n+k-(j+i+1)-1
        n = n+k
        break
      end
    end
  end
end

puts count