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

l.sort!
ans = 0
left = 0

while left < n-1
  l[left+1..n-1].combination(2) { |b, c|
    # b < cと仮定
    if l[left] + b > c
      # p [l[left], b, c]
      ans += 1
    end
  }
  left += 1
end

p ans
