lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
longeurs = lines[1].sort

ans = 0
for i in 1..N-2 do
  for j in i+1..N-1 do
    l = longeurs[j..-1]
    num = l.bsearch_index{|x| x >= longeurs[i-1] + longeurs[j-1]}
    if num != nil then
      ans += num
    else
      ans += l.length
    end
  end
end
  
print ans