n = gets.chomp.to_i
l_arr = gets.chomp.split(" ").map(&:to_i).sort!

count = 0
(0..(l_arr.length-3)).each do |i|
  ((i+1)..(l_arr.length-2)).each do |j|
    sum = l_arr[i] + l_arr[j]
    ((j+1)..(l_arr.length-1)).each do |k|
      break if sum <= l_arr[k]
      count += 1
    end
  end
end

puts count

