io = STDIN
n=io.gets.to_i
l=io.gets.split.map(&:to_i).sort
cnt=0
l[0..-3].each_with_index do |a,i|
   l[i+1..-2].each_with_index do |b,j|
      ab=a+b
      l[i+j+2..-1].each do |c|
        break if c>=ab
        cnt+=1 if a<b+c && b<a+c
      end
   end
end
p cnt
