n=gets.strip.to_i
ll=gets.strip.split.map(&:to_i).sort

#p ll

result=0
(n-1).downto(2) do |i|
  l=0
  r=i-1
  while l<r
#p [l, r, i, (r-l)]
    if ll[i] < ll[l]+ll[r]
      result += (r-l)
      r -= 1
    else
      l += 1
    end
  end
end

p result
