def bsearch(ary, s, n, t)
  r = n
  l = s
  c = (s + n) / 2
  return 0 if ary[s] >= t
  return n-s if ary[n-1] < t
  until ary[c-1] <= t && ary[c] > t
    if ary[c] < t
      l = c
    else
      r = c
    end
    c = (l + r) / 2
  end
  c-s
end

n = gets.to_i
l = gets.split.map(&:to_i).sort
count = 0
(0...n-2).each do |a|
  (a+1...n-1).each do |b|
    count += bsearch(l, b+1, n,  l[a] + l[b])
  end
end
  
puts count