N=gets.to_i
l=[]
l=gets.chomp.split(" ").map{|i| i.to_i}
num_of_tri=0

for i in 0..N-3 do
  for j in i+1..N-2 do
    for k in j+1..N-1 do
      if l[i]<l[j]+l[k] && l[j]<l[i]+l[k] && l[k]<l[i]+l[j] then
        num_of_tri+=1
      end
    end
  end
end

print("#{num_of_tri}")
