n = gets.to_i
l = gets.split(" ", n).map(&:to_i)

ans = 0
l.sort!{|a, b| b <=> a }
0.upto(l.length-3) do |i|
  (i+2).upto(l.length-1) do |j|
    tmp = l.slice(i+1, j-i-1)
    bi = tmp.bsearch_index{|x| x < l[i] + l[j] && l[i] < x + l[j] && l[j] < x + l[i]}
    unless bi.nil?
      ans += tmp.length - bi
    end
  end
end
p ans