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

cnt = 0

l.sort!.reverse!

flg = false

(0...n-2).each do |a|
  (a+1...n-1).each do |b|
    break if l[a] > l[b]*2
    (b+1...n).each do |c|
      if l[a] > l[b] + l[c]
        flg = true
        break
      end
      if l[a] + l[b] > l[c] && l[b] + l[c] > l[a] && l[c] + l[a] > l[b]
        cnt += 1
      end
    end
    if flg
      flg = false
      break
    end
  end
end
puts cnt