sticks_length = gets.chomp.to_i
sticks = gets.chomp.split.map(&:to_i)

sticks_asc = sticks.sort_by{ |stick| stick }

result = 0

(sticks_length - 1).downto(2) do |i|
  (i - 1).downto(1) do |j|

    # 2辺が固定されたのであと1本の必要な長さがわかる
    min_length = sticks_asc[i] - sticks_asc[j]
    # 短すぎる枝の数
    small_stick_num = sticks_asc.bsearch_index {|stick| min_length < stick }
    result += [j - small_stick_num, 0].max
  end
end

puts result