#https://atcoder.jp/contests/abc143/submissions/10478260
N=gets.to_i
L=gets.split.map(&:to_i).sort.reverse

ans = 0
(0..N-2).each do |i|
  j, k = i+1, N-1
  while j < k
    if L[i] < L[j] + L[k]
      ans += k-j
      j += 1
    else
      k -= 1
    end
  end
end
puts ans