N = gets.chomp.to_i
inputs = gets.chomp.split("")
count = 0
inputs.each_with_index do |e,i|
  e = e.to_i
  j= i+1
  k= j+1
  while j < N-1 do
    f = inputs[j].to_i
    while k < N do
      g = inputs[k].to_i
      if (e + g > f)&&(f + g > e)&&(e + f > g)
        count +=1
      end
      k += 1
    end
    j += 1
    k = j+1
  end
end

puts count
