n = gets.to_i
a = gets.split.map &:to_i
a.sort!

def count(lo,hi,ok)
  while hi - lo > 1
    mid = (hi + lo) / 2
    ok[mid] ? lo = mid : hi = mid
  end
  lo
end

ans = 0
(n-2).times do |i|
  (i+1).upto(n-2) do |j|
    k = a[i] + a[j]
    ok = -> mid { a[mid] < k }
    ans += count(j,n,ok) - j
  end
end

puts ans