N = gets.to_i
L = gets.chomp.split(" ").map(&:to_i).sort

ans = 0
(1...(N-1)).each{|i|
  w = 0
  ((i+1)..(N-1)).each{|j|
    until L[w] > L[j] - L[i] do w += 1 end
    break if w >= i
    ans += (i - w)
  }
}

puts ans
