N = gets.to_i
Ary = gets.split.map(&:to_i)
count = 0
Ary.each.with_index do |a, i|
  break if i == Ary.size - 1
  Ary[(i+1)..-1].each.with_index do |b, j|
    Ary[(i+j+2)..-1].each do |c|
      if a + b > c && c > [a, b].max - [a, b].min
        count += 1
      end
    end
  end
end

puts count
